public class SwingApplication {
public static void main(String[] args) {
JFrame frame = new JFrame("SwingApplication");
//...create the components to go into the frame...
//...stick them in a container named contents...
frame.getContentPane().add(contents,
BorderLayout.CENTER);
//Finish setting up the frame, and show it.
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
JButton button = new JButton("call other frame");
button.addActionListener(this);
JPanel pane = new JPanel();
pane.setBorder(BorderFactory.createEmptyBorder(30, 30, 10, 30));
pane.setLayout(new GridLayout(0, 1));
pane.add(button);
//when somebody clicks in jbutton it calls the subforms
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Secondform 2form= new Secondform ();
2form.pack();
2form.setVisible(true);
}
});