Home > Back-end >  Simple form
Simple form

Time:10-09

Import the Java. The awt. Container;
Import the Java. The awt. FlowLayout;
Import the Java. The awt. Frame;
Import the Java. The awt. Event. An ActionEvent;
Import the Java. The awt. Event. ActionListener;
The import javax.mail. Swing. JButton;
The import javax.mail. Swing. JDialog;
The import javax.mail. Swing. JFrame;
The import javax.mail. Swing. JLabel;
Public class Demo extends JDialog {
Public Demo (JFrame frame) {
/*
* the first parameter, the parent window object
* the second parameter, title of the dialog
* the third parameter, whether blocking the parent form
*
* */
Super (frame, "dialog title", true);
The Container c=getContentPane ();
C.a. dd (new JLabel (" this is a dialog box ")); SetBounds (100, 100, 100, 100);//set the form coordinates and size
}
Public static void main (String [] args) {
JFrame f=new JFrame (" parent form ");
F.s etBounds (50, 50, 300, 300);
The Container c=f.g etContentPane ();
JButton BTN=new JButton (" pop-up dialog "); C.s. etLayout (new FlowLayout ());//set up the layout, using flow layout c.a. dd (BTN);
F.s etVisible (true); F.s etDefaultCloseOperation (EXIT_ON_CLOSE); BTN. AddActionListener (new ActionListener () {@ Override
Public void actionPerformed (an ActionEvent e) {
The Demo d=new Demo (f);
D.s etVisible (true);//Settings window visible
}
});
}
}
  • Related