List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(new JButton("A")); frame.add(buttonPanel);// ww w .j a v a2 s. co m frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel buttonPanel = new JPanel(new FlowLayout(), true); buttonPanel.add(new JButton("A")); frame.add(buttonPanel);/*from www. j av a2s .c om*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//from w ww. j av a 2 s . c o m frame.add(new JButton("1")); frame.add(new JButton("2")); gbl.layoutContainer(frame); gbl.columnWeights = new double[] { 0.0f, 1.0f, 2.0f }; gbl.rowWeights = new double[] { 0.0f, 1.0f }; frame.pack(); frame.setVisible(true); }
From source file:FrameClose2.java
public static void main(String[] args) { JFrame mainFrame = new JFrame(); // Exit app when frame is closed. mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0);/*from w ww.j a v a2s. c om*/ } }); mainFrame.setSize(320, 240); mainFrame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(new GridLayout(10, 10, 10, 10)); for (int i = 0; i < 100; i++) { panel.add(new JButton(String.valueOf(i))); }//from w w w . j a v a 2s . co m frame.add(panel); frame.setSize(600, 600); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setSize(400, 400);/*w w w. ja va2 s. c o m*/ f.add(new MainClass()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); Container content = root.getContentPane(); content.add(new JButton("Hello")); f.pack();/* w w w. j a v a 2 s . co m*/ f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pnl = new JPanel(); pnl.add(new MyButton()); frame.add(pnl);// w w w . ja v a2 s . c om frame.setSize(600, 600); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container content = frame.getContentPane(); content.setLayout(new GridLayout(0, 2)); JTextArea leftTextArea = new JTextArea(); content.add(leftTextArea);//from w w w .ja v a2s. com leftTextArea.paste(); frame.setSize(250, 150); frame.setVisible(true); }
From source file:TimerSample.java
public static void main(String args[]) { new JFrame().setVisible(true); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hello World Timer"); }//from ww w. j a v a 2 s. c o m }; Timer timer = new Timer(500, actionListener); timer.start(); }