If you use JBuilder's visual design tool, you must have the following conditions:
1. The classes included in the Java file cannot make internal or anonymous classes
2. Class name must be the same as the file name
3. No syntax error
/ ** * JBuilder GUI Designer automatically generates the structure of the code * /
Import javax.swing. *; import java.awt.Event.Ava.awt.Event.windowEvent;
Public Class Exampleframe Extends JFrame {// Create Components
Public exampleframe () {Try {jbinit ();
} Catch (exception e) {E.PrintStackTrace ();}}
/ * ** Close interface * @param e WindowEvent * / protected void processWindowEvent (WindowEvent e) {super.processWindowEvent (e); if (e.getID () == WindowEvent.WINDOW_CLOSING) {System.exit (0);} }
Private void jbinit () throws exception {// initialization of each component}
Void JMenuitem1_ActionPerformed (ActionEvent E) {// Menu Function Definition}
}
/ ** * Event listener * / class servermonitornew_jmenuitem1_actionAdapter Implements java.awt.event.Adlistener {Exampleframe Adaptee;
ServerMonitorNew_jmenuitem1_ActionAdapter (Exampleframe Adaptee) {this.adaptee = adaptee;}
Public void ActionPerformed (ActionEvent E) {adaptee.jmenuitem1_actionperformed (e);}}
Be careful when setting the layout, each container has a single layout setting, can not be mixed, it may cause Stackoverflow