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:CloseAction.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JButton closeButton = new JButton(new CloseAction()); contentPane.add(closeButton);/*from ww w . j a va2 s.co m*/ frame.pack(); frame.setVisible(true); }
From source file:ActionListenerTest3.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 ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println(fileChooser.getSelectedFile().getName()); }/*from w w w . j a v a2 s .c om*/ } }); frame.add(button); frame.pack(); frame.setVisible(true); }
From source file:GettingSettingSelectedItem.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton jButton1 = new JButton("Button"); String[] mystring = { "Java", "JBuilder", "JFC", "Swing" }; final JList jList1 = new JList(mystring); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { Object contents = jList1.getSelectedValue(); System.out.println(contents); }/*from w ww . j av a2 s . c o m*/ }); frame.add(jList1, "Center"); frame.add(jButton1, "South"); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Bring me to top after 3 seconds"); button.addActionListener(e -> triggerBringToFront(f, 3000)); f.getContentPane().add(button);/*from w w w. j av a 2s. c o m*/ f.pack(); f.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Popup JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new BasicArrowButton(BasicArrowButton.NORTH), BorderLayout.NORTH); frame.add(new BasicArrowButton(BasicArrowButton.EAST), BorderLayout.EAST); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH), BorderLayout.SOUTH); frame.add(new BasicArrowButton(BasicArrowButton.WEST), BorderLayout.WEST); frame.setSize(300, 200);// w ww . ja va2 s. c om frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("ProgressBars"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar dJProgressBar = new JProgressBar(JProgressBar.VERTICAL); dJProgressBar.setValue(100);// ww w .j a v a 2 s . c o m dJProgressBar.setBorderPainted(false); dJProgressBar.setString("Ack"); dJProgressBar.setStringPainted(true); frame.add(dJProgressBar, BorderLayout.WEST); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ToggleButtonSample.java
public static void main(String args[]) { JFrame f = new JFrame("JToggleButton Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); content.add(new JToggleButton("North"), BorderLayout.NORTH); content.add(new JToggleButton("East"), BorderLayout.EAST); content.add(new JToggleButton("West"), BorderLayout.WEST); content.add(new JToggleButton("Center"), BorderLayout.CENTER); content.add(new JToggleButton("South"), BorderLayout.SOUTH); f.setSize(300, 200);/*from w w w. j a v a 2s . c o m*/ f.setVisible(true); }
From source file:DoubleTitle.java
public static void main(String args[]) { JFrame frame = new JFrame("Double Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM); JButton doubleButton = new JButton(); doubleButton.setBorder(doubleBorder); Container contentPane = frame.getContentPane(); contentPane.add(doubleButton, BorderLayout.CENTER); frame.setSize(300, 100);/*w ww.ja va 2 s. co m*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { final String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Multi-Columns"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList columns = new JList(labels); columns.setLayoutOrientation(JList.HORIZONTAL_WRAP); columns.setVisibleRowCount(3);// w w w . j a v a2 s . c o m JScrollPane sp = new JScrollPane(columns); frame.add(sp, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Selecting CheckBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JCheckBox checkBox = new JCheckBox("Hi"); checkBox.getModel().setMnemonic((char) 'H'); System.out.println(checkBox.getModel().getMnemonic()); frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100);/* w w w. j av a 2 s . c o m*/ frame.setVisible(true); }