List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:JToggleButtonEvents.java
public static void main(String[] args) { JToggleButton jtb = new JToggleButton("Press Me"); jtb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { System.out.println("ActionEvent!"); }/*from w w w .j a v a 2 s. c o m*/ }); jtb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); } }); jtb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setLayout(new FlowLayout()); c.add(jtb); f.pack(); f.setVisible(true); }
From source file:TextAreaElements.java
public static void main(String[] args) { try {/*w w w .j av a 2 s. co m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Text Area Elements"); JTextArea ta = new JTextArea(5, 32); ta.setText("That's one small step for man...\nOne giant leap for mankind."); f.getContentPane().add(ta); f.pack(); f.setVisible(true); ((AbstractDocument) ta.getDocument()).dump(System.out); }
From source file:JTextAreaDemo.java
public static void main(String[] args) { JFrame frame = new JTextAreaDemo(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// w w w . ja v a 2 s .c om } }); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JProgressBar progressBar = new JProgressBar(0, 10); final CounterTask task = new CounterTask(); task.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); }/* w w w . ja v a 2 s .c om*/ } }); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { task.execute(); } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { task.cancel(true); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(startButton); buttonPanel.add(cancelButton); JPanel cp = new JPanel(); LayoutManager layout = new BoxLayout(cp, BoxLayout.Y_AXIS); cp.setLayout(layout); cp.add(buttonPanel); cp.add(progressBar); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(cp); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Main mainPanel = new Main(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(mainPanel);//w w w .ja v a 2 s .c o m f.setJMenuBar(mainPanel.createMenuBar()); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JProgressBar pb = new JProgressBar(); JTextArea ta = new JTextArea(10, 20); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(ta)); frame.add(pb, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true);/*from ww w . ja v a 2 s . c om*/ new BackgroundWorker(ta, pb).execute(); }
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(); f.setVisible(true);/*from w w w. j av a 2s .co m*/ }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new Main()); frame.validate();/*from ww w . j a v a2 s . c o m*/ frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { MainPanelGen mainPanelGen = new MainPanelGen(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanelGen.getMainPanel()); frame.pack(); frame.setVisible(true);// w ww . j a v a 2 s . c om }
From source file:Main.java
public static void main(String args[]) { UIManager.put("ProgressBar.repaintInterval", 100); UIManager.put("ProgressBar.border", BorderFactory.createLineBorder(Color.blue, 2)); JFrame f = new JFrame(); f.setLayout(new GridLayout(0, 1, 5, 5)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(createBar());/*from w w w. j a v a2 s . c om*/ f.add(createBar()); f.add(createBar()); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }