Hallo,
ich bin Anfängerin in Sachen Java Swing und bräuchte einmal ein paar Ratschläge und Tips. Ich habe mein erstes Swing-Fenster erstellt und es enthält 3 Buttons. Nun habe ich Probleme, wie ich die Buttons verlinke. Die Adapterklasse heißt LoginWindowAdapter. Hier mal mein bisheriger Code:
package windows_client;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import language_client.PropertyManager;
import adapter_client.LoginWindowAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*
* Created on 20.05.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Simone
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class LoginWindow extends JFrame {
Dimension dim;
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel(UIManager.get SystemLookAndFeelClassName());
} catch(Exception e) {
e.printStackTrace();
}
}
public LoginWindow( Dimension dim )
{
super( "RoboRally" + " - " + PropertyManager.getProperty("LOGIN"));
initGui(dim);
}
LoginWindowAdapter LWA = new LoginWindowAdapter(){
public void actionPerformed(ActionEvent arg0){
AbstractButton login = null;
if (arg0.getActionCommand().equals(???getActionComman d())){
}
AbstractButton register = null;
if (arg0.getActionCommand().equals(???.getActionComma nd())){
}
AbstractButton server = null;
if (arg0.getActionCommand().equals(???.getActionComma nd())){
}
}
};
public void initGui(Dimension dim)
{
Container c = this.getContentPane();
c.setLayout( new BorderLayout(5,5) );
c.setLayout( new GridLayout(8,0,0,0) );
c.add( new JLabel("RoboRally" + " - " + PropertyManager.getProperty("LOGIN")));
c.add( new JLabel() );
c.add( new JLabel() );
c.add( new JLabel() );
c.add( new JLabel(PropertyManager.getProperty("name")+":"));
c.add( new JTextField());
c.add( new JLabel(PropertyManager.getProperty("password")+":" ) );
c.add( new JPasswordField() );
c.add( new JLabel() );
c.add( new JLabel() );
c.add( new JLabel() );
c.add( new JButton(PropertyManager.getProperty("login")+":") );
c.add( new JLabel() );
c.add( new JLabel() );
c.add( new JButton(PropertyManager.getProperty("server")));
c.add( new JButton(PropertyManager.getProperty("register")));
//center window
this.setLocation((int)(dim.width/3),(int)(dim.height/3));
this.setSize( (int)dim.getWidth()/3,(int) dim.getHeight()/3 );
this.setVisible( true );
}
}
Wäre toll, wenn ihr mir helfen könntet.
LG
Simone