![]() |
Hilfe zu Java-Code 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.getSystemLookAndFeelClassName()); } 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(???getActionCommand())){ } AbstractButton register = null; if (arg0.getActionCommand().equals(???.getActionCommand())){ } AbstractButton server = null; if (arg0.getActionCommand().equals(???.getActionCommand())){ } } }; 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 |
AW: Hilfe zu Java-Code Lies die Javadoc und die Sun-Tutorials zum thema EventListener, da steht alles drin. |
AW: Hilfe zu Java-Code Kann ich ebenfalls nur empfehlen, [url="http://java.sun.com/docs/books/tutorial/uiswing/events/index.html"]Link.[/url] Besser kann man´s nicht erklären. |
| Alle Zeitangaben in WEZ +1. Es ist jetzt 08:47 Uhr. |
Powered by vBulletin® Version 3.8.10 (Deutsch)
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
SEO by vBSEO 3.5.2 ©2010, Crawlability, Inc.