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:LinesDashes3.java
public static void main(String[] args) { LinesDashes3 lines = new LinesDashes3(); JFrame frame = new JFrame("Lines"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(lines);/* w ww .j a va2 s . com*/ frame.setSize(280, 270); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:BasicArrowButtonSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Popup JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(0, 5)); frame.add(new BasicArrowButton(BasicArrowButton.EAST)); frame.add(new BasicArrowButton(BasicArrowButton.NORTH)); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH)); frame.add(new BasicArrowButton(BasicArrowButton.WEST)); frame.setSize(300, 200);//from ww w . ja v a 2s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("Hello"); label.setOpaque(true);/*from w w w . java 2s . com*/ label.setBackground(Color.red); JPanel bottomPanel = new JPanel(new BorderLayout()); bottomPanel.add(label, BorderLayout.LINE_END); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(bottomPanel, BorderLayout.PAGE_END); mainPanel.setPreferredSize(new Dimension(400, 400)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:RegisterChangeListenerToJSlider.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL, 10, 100, 20); framesPerSecond.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int fps = (int) source.getValue(); System.out.println(fps); }//from www . j av a 2 s . c om } }); frame.add(framesPerSecond, "North"); 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().setArmed(false); frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100);/*w w w . j a v a2s.c o m*/ 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().setEnabled(false); frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100);//from w w w. j a v a2 s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); // Add a close button JButton closeButton = new JButton("Close"); contentPane.add(closeButton);//from w w w . j a v a 2 s .c o m closeButton.addActionListener(e -> { System.out.println(e.getActionCommand()); System.exit(0); }); frame.pack(); frame.setVisible(true); }
From source file:LinesDashes2.java
public static void main(String[] args) { LinesDashes2 lines = new LinesDashes2(); JFrame frame = new JFrame("Lines"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(lines);/* w w w. j a v a 2 s . c o m*/ frame.setSize(280, 270); frame.setLocationRelativeTo(null); 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().setActionCommand("Hi"); frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100);/*from w w w . ja v a 2 s . com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); JLabel label = new JLabel("User Name:", SwingConstants.RIGHT); JLabel label2 = new JLabel("Password:", SwingConstants.RIGHT); JTextField userNameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(); passwordField.setEchoChar('#'); frame.add(label);// w w w . j a v a 2 s . c o m frame.add(userNameField); frame.add(label2); frame.add(passwordField); frame.setSize(200, 70); frame.setVisible(true); }