Næste |
|
Swing'it! serie, Planche nr. 17 |
![]() |
Ex.: Sæt topniveau |
Der er kun et topniveau, en JFrame
public class SwingApplication ... { ... public SwingApplication() { //Create the top-level container. JFrame frame = new JFrame("SwingApplication"); //...create a JButton and a JLabel... //...add them to a JPanel... //Add the JPanel to the frame. frame.getContentPane().add(pane, 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); } ... }