Studyon Minte9.com
Java SE




Frame



Open a frame (600x400) and exit app when closed.

package testexample; import java.awt.*; import javax.swing.*; public class Test extends JFrame { // --- Look Here --- // public static void main(String[] args) { Test frame = new Test(); frame.setBounds(200, 200, 600, 400); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); //frame.setLayout(new BorderLayout()); frame.setVisible(true); } public Test() { JLabel label = new JLabel("My message"); JPanel panel = new JPanel(); panel.add(label); panel.setForeground(Color.red); add(panel); } }