List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] args) { JFrame frame1 = new JFrame(); frame1.setExtendedState(JFrame.MAXIMIZED_BOTH); frame1.setUndecorated(true);//from w w w.ja v a2 s . c o m frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setVisible(true); JDialog nonModalDialog = new JDialog(frame1, "Non-Modal Dialog", ModalityType.MODELESS); nonModalDialog.add(Box.createRigidArea(new Dimension(200, 200))); nonModalDialog.pack(); nonModalDialog.setVisible(true); JDialog modalDialog = new JDialog(frame1, "Modal Dialog", ModalityType.APPLICATION_MODAL); modalDialog.add(Box.createRigidArea(new Dimension(200, 200))); modalDialog.pack(); modalDialog.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 w w . j av a 2 s . c o m*/ JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); 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 ww w. j ava 2 s .co m JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); ButtonGroup group = new ButtonGroup(); JRadioButton option = new JRadioButton("French Fries", true); group.add(option);/* ww w .j a v a 2s . co m*/ contentPane.add(option); option = new JRadioButton("Onion Rings", false); group.add(option); contentPane.add(option); option = new JRadioButton("Ice Cream", false); group.add(option); contentPane.add(option); frame.setSize(200, 200); frame.show(); }
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 w w . j av a2 s .c om JButton component = new JButton("1"); frame.add(component); frame.add(new JButton("2")); gbl.layoutContainer(frame); GridBagConstraints gbc = new GridBagConstraints(); // Make the component on stretchable gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(component, gbc); frame.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea textarea1 = new JTextArea(); Document document = textarea1.getDocument(); JTextArea textarea2 = new JTextArea(document); JTextArea textarea3 = new JTextArea(document); frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); frame.add(new JScrollPane(textarea1)); frame.add(new JScrollPane(textarea2)); frame.add(new JScrollPane(textarea3)); frame.setSize(300, 400);/*from w w w . j a va 2 s. c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame horizontalFrame = new JFrame(); horizontalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent leftButton = new JButton("Left"); JComponent rightButton = new JButton("Right"); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setLeftComponent(leftButton); splitPane.setRightComponent(rightButton); horizontalFrame.add(splitPane, BorderLayout.CENTER); horizontalFrame.setSize(150, 150);/*from w w w . j ava 2s .c om*/ horizontalFrame.setVisible(true); }
From source file:InternalFramePaletteSample.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);/*from www .j av a 2 s. c o m*/ frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 300);/* w w w. ja va 2s. c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("System LAF Demo"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame result = new JFrame(); JComboBox<String> combobox = new JComboBox<>(new String[] { "foo", "bar", "aaa", "Hello World" }); result.add(combobox, BorderLayout.CENTER); JCheckBox toggleVisibility = new JCheckBox("Toggle visibility"); toggleVisibility.setSelected(combobox.isVisible()); toggleVisibility.addItemListener(e -> { combobox.setVisible(e.getStateChange() == ItemEvent.SELECTED); });/* www . ja va 2 s. c o m*/ result.add(toggleVisibility, BorderLayout.SOUTH); result.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result.pack(); result.setVisible(true); }