|
import java.awt.*; import javax.swing.*; |
|
(it has borders and a toolbar that the user can use to minimize, close and maximize the window)
import javax.swing.*; public class DemoJFrame1 { public static void main(String args[]) { JFrame f = new JFrame("Hello World!"); // Make new JFrame object f.setSize(400, 300); // Set size of window f.setVisible(true); // Show window } } |
We will focus on the components used for graphical programming
|
|
(otherwise, people will hate your GUI)...
|
|
import javax.swing.*; public class DemoJFrame2 { public static void main(String args[]) { JFrame f = new JFrame("Hello World!"); f.setSize(400, 300); JLabel L = new JLabel("I am a label !"); f.getContentPane().add(L); // Stick label L on contentPane f.setVisible(true); } } |
|
|