Java Reference
In-Depth Information
Display 17.4 The Normal Way to Define a JFrame (part 2 of 2)
12
setDefaultCloseOperation(
13
JFrame.DO_NOTHING_ON_CLOSE);
14
JButton endButton = new JButton("Click to end program.");
15
endButton.addActionListener( new EndingListener());
16
add(endButton);
17
}
18
}
The class EndingListener is defined in Display
17.2.
This is the file FirstWindow.java .
This is the file DemoWindow.java .
1 public class DemoWindow
2{
3 public static void main(String[] args)
4 {
5 FirstWindow w = new FirstWindow();
6 w.setVisible( true );
7 }
8}
R ESULTING GUI
 
Search WWH ::




Custom Search