List of usage examples for javax.swing JFrame setDefaultCloseOperation
@BeanProperty(preferred = true, enumerationValues = { "WindowConstants.DO_NOTHING_ON_CLOSE", "WindowConstants.HIDE_ON_CLOSE", "WindowConstants.DISPOSE_ON_CLOSE", "WindowConstants.EXIT_ON_CLOSE" }, description = "The frame's default close operation.") public void setDefaultCloseOperation(int operation)
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); desktop.add(internalFrame);// w w w .j a v a 2 s . co m internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); DesktopManager desktopManager = desktop.getDesktopManager(); desktopManager.resizeFrame(internalFrame, 20, 20, 200, 200); 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("Compound Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bevelLineButton = new JButton("Bevel Line"); Border redBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2, true); bevelLineButton.setBorder(redBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(bevelLineButton);// w ww. j av a2 s .c o m frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Empty Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border emptyBorder = BorderFactory.createEmptyBorder(20, 20, 0, 0); JButton emptyButton = new JButton("With Empty"); emptyButton.setBorder(emptyBorder);//from ww w .j a v a2 s.co m JButton nonemptyButton = new JButton("Without Empty"); Container contentPane = frame.getContentPane(); contentPane.add(emptyButton, BorderLayout.NORTH); contentPane.add(nonemptyButton, BorderLayout.SOUTH); frame.pack(); frame.setSize(300, frame.getHeight()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<Vector<String>> rowData = new Vector<Vector<String>>(); Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1")); for (int i = 0; i < 2000; i++) { rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i)))); }/* w w w.jav a2 s .c o m*/ JTable table = new JTable(rowData, columnName); JScrollPane scrollPane = new JScrollPane(table); JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setPreferredSize(new Dimension(0, 0)); f.add(scrollPane); f.pack(); f.setVisible(true); JViewport view = scrollPane.getViewport(); Component[] components = view.getComponents(); for (int i1 = 0; i1 < components.length; i1++) { if (components[i1] instanceof JTable) { System.out.println("got"); } } }
From source file:BoxLayoutDemo.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); p.add(createComponent("Component 1")); p.add(Box.createVerticalGlue()); p.add(createComponent("Component 2")); p.add(createComponent("Component 3")); p.add(createComponent("Component 4")); frame.setContentPane(p);// ww w.j ava 2 s .c o m //Display the window. frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); desktop.add(internalFrame);/*from w ww.ja va2 s.c o m*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); DesktopManager desktopManager = desktop.getDesktopManager(); desktopManager.deiconifyFrame(internalFrame); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); desktop.add(internalFrame);// ww w. j a v a 2 s. co m internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); DesktopManager desktopManager = desktop.getDesktopManager(); desktopManager.setBoundsForFrame(internalFrame, 20, 20, 200, 200); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:MyComboBoxModel.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox cbox = new JComboBox(new MyComboBoxModel()); cbox.setMaximumRowCount(5);//ww w. j a va2s .c o m frame.add(cbox); frame.setSize(300, 200); frame.setVisible(true); }
From source file:GradientsLine.java
public static void main(String[] args) { JFrame frame = new JFrame("GradientsLine"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new GradientsLine()); frame.setSize(350, 350);/* w ww. j a va 2s.c o m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); boolean b = fileChooser.getControlButtonsAreShown(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack();/* w w w.j av a 2 s. c om*/ frame.setVisible(true); }