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:RootExample2.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); // Create a menu bar JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); bar.add(menu);/*w w w . j a v a2 s . co m*/ menu.add("Open"); menu.add("Close"); root.setJMenuBar(bar); // Add a button to the content pane root.getContentPane().add(new JButton("Hello World")); // Display the UI f.pack(); f.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 ww w. j a v a 2s .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.maximizeFrame(internalFrame); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JTable(new Object[][] { { 1, 2, 3 }, { 4, 5, 6 } }, new Object[] { "one", "two", "three" }) { {/*from w w w. j a v a 2 s . c o m*/ addMouseMotionListener(new MouseAdapter() { @Override public void mouseDragged(MouseEvent e) { System.out.println("mouseDragged"); } @Override public void mousePressed(MouseEvent e) { System.out.println("mousePressed"); } @Override public void mouseReleased(MouseEvent e) { System.out.println("mouseReleased"); } }); } }); f.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new JFrame("GridBag1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(225, 150);/*from w w w.j a va2 s .co m*/ frame.setLocation(200, 200); frame.setContentPane(new MainClass()); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new Main(); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setSize(20, 200);/*from w ww . jav a2s . com*/ 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 textField = new JTextField("A TextField"); textField.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { displayMessage("Focus gained", e); }// www .j ava 2 s.co m public void focusLost(FocusEvent e) { displayMessage("Focus lost", e); } void displayMessage(String prefix, FocusEvent e) { System.out.println(e.getID() == FocusEvent.FOCUS_LOST); } }); frame.add(textField, "North"); frame.add(new JTextField(), "South"); frame.setSize(300, 200); 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(); textField.setHorizontalAlignment(JTextField.CENTER); label.setLabelFor(textField);/*ww w.j a v a 2s . co m*/ 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.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new TextBoundaryFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();// w ww . j a va 2s .co m frame.show(); }
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 w w. ja v a 2 s. c om 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.openFrame(internalFrame); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String[] items = { "A", "B", "C" }; JComboBox<String> comboBox1 = new MyComboBox1<>(items); JPanel p = new JPanel(); p.add(comboBox1);/* w w w . j a v a2s . co m*/ JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(p); f.setSize(320, 240); f.setVisible(true); }