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) { JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JPanel panel2 = new JPanel(new BorderLayout()); panel2.add(new JButton("NORTH"), BorderLayout.NORTH); panel2.add(new JButton("CENTER")); panel.add(panel2);//from w w w .jav a2 s. co m panel.add(new JButton("SOUTH"), BorderLayout.SOUTH); panel.add(new JButton("EAST"), BorderLayout.EAST); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:ButtonFocus.java
public static void main(String args[]) { JFrame frame = new JFrame("Focus Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton focusButton = new JButton("Focused"); JButton notFocusButton = new JButton("Not Focused"); frame.setLayout(new FlowLayout()); frame.add(focusButton);//ww w . j a v a 2 s . c om frame.add(notFocusButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JButton close = new JButton("Close me programmatically"); final JFrame f = new JFrame("Close Me"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(close);//from w w w.j a v a 2 s.co m close.addActionListener(e -> { f.dispose(); }); f.pack(); f.setLocationByPlatform(true); f.setVisible(true); }
From source file:SettingDefaultButton.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button4 = new JButton("AAA"); frame.add(button4, "Center"); frame.add(new JButton("BBB"), "South"); JRootPane rootPane = frame.getRootPane(); rootPane.setDefaultButton(button4);// w w w.j a v a2s.c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField jTextField1 = new JTextField(); jTextField1.setText("jTextField1"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action"); }// ww w . jav a2 s . c o m }); frame.add(jTextField1); frame.setSize(300, 200); frame.setVisible(true); }
From source file:SpinnerDateSample.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("Dates/Date"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.CENTER); frame.setSize(200, 90);/*w ww .j a v a2s. co m*/ frame.setVisible(true); }
From source file:RelativeX.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0;/* ww w. j a v a2 s.co m*/ pane.add(new JButton("First row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; gbc.gridy = 1; pane.add(new JButton("Second row, first column"), gbc); pane.add(new JButton("Second row, second column"), gbc); pane.add(new JButton("Second row, third column"), gbc); gbc.gridy = 2; pane.add(new JButton("Third row"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JLabel Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 18)); label.setForeground(Color.RED); frame.add(label);//from ww w .j a v a2s. co m frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Adornment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true);/*w w w.j a v a 2s . c o m*/ frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MainFrameBorderLayout.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel outerPanel = new JPanel(new BorderLayout()); JPanel topPanel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name:"); JTextField text = new JTextField(); topPanel.add(label, BorderLayout.BEFORE_LINE_BEGINS); topPanel.add(text, BorderLayout.CENTER); outerPanel.add(topPanel, BorderLayout.BEFORE_FIRST_LINE); frame.add(outerPanel);/*from ww w .ja v a2 s . c o m*/ frame.setSize(300, 200); frame.setVisible(true); }