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(String[] args) { String[] headers = { "column 1", "column 2", "column 3", "column 4" }; int cols = 4; int rows = 6; String[][] data = new String[rows][cols]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { data[row][col] = "item " + (row * cols + col + 1); }//from w w w.ja v a 2 s. c o m } JTable table = new JTable(data, headers); DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class); renderer.setHorizontalAlignment(JLabel.RIGHT); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(table)); f.setSize(400, 400); f.setLocation(200, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToolBar toolBar = new JToolBar("Still draggable"); toolBar.setFloatable(false);//from w w w . j a v a2 s. c o m toolBar.setRollover(true); toolBar.add(new JButton("New")); toolBar.addSeparator(); toolBar.add(new JButton("Open")); frame.add(toolBar, "North"); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ActionListenerTest2.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Select File"); button.addActionListener(new MyActionListener()); frame.add(button);//from w ww . j a va 2 s .c o m frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox<String> comboBox = new JComboBox<>(new String[] { "Something", "Stuff", "Beep" }); JButton add = new JButton("Add item"); add.addActionListener(new ActionListener() { @Override/*from w ww . j av a2 s .com*/ public void actionPerformed(ActionEvent e) { comboBox.addItem("Item"); } }); frame.add(comboBox); frame.add(add, BorderLayout.SOUTH); 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); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); textField.setHorizontalAlignment(JTextField.CENTER); label.setLabelFor(textField);//from w ww .j av a 2 s.c o m panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:OvalPanelCanvas.java
public static void main(String args[]) { JFrame frame = new JFrame("Oval Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new OvalPanelCanvas()); frame.setSize(300, 200);/*from ww w .j a v a 2 s .com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Layout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout()); for (int i = 1; i <= 5; i++) { contentPane.add(new JButton("Button " + i)); }/* w w w . j ava 2s . c o m*/ frame.pack(); frame.setVisible(true); }
From source file:Rotate.java
public static void main(String[] args) { JFrame frame = new JFrame("Rotation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Rotate()); frame.setSize(300, 200);//from w w w. j a v a 2 s. c om frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL); bar.setEnabled(true);//from ww w . j av a 2 s . c o m bar.setBackground(Color.YELLOW); bar.setForeground(Color.GREEN); bar.setStringPainted(true); bar.setString("2000 g"); bar.setValue(65); frame.setLayout(new BorderLayout()); frame.add(bar, BorderLayout.CENTER); frame.setSize(500, 400); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);/*from w w w. j av a 2s . c om*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }