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:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JTable Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rows[][] = { { "A", "Name 1", "38.94" }, { "B", "Name 2", "7.70" }, { "C", "Name 3", "112.65" } }; Object columns[] = { "Symbol", "Name", "Price" }; JTable table = new JTable(rows, columns); JScrollPane scrollPane = new JScrollPane(table); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200);//from w w w . ja v a2 s. c o m f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);//from ww w .j a va 2 s . co m f.pack(); f.setVisible(true); }
From source file:Main.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.PAGE_END); topPanel.add(text, BorderLayout.CENTER); outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE); frame.add(outerPanel);//ww w . j av a 2s.c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);//from w w w . j ava 2 s . co m frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setPopupMenuVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Add a close button JButton closeButton = new JButton("Close"); Container contentPane = frame.getContentPane(); contentPane.add(closeButton);/* ww w. j a v a 2s.c o m*/ // Calculates and sets appropriate size for the frame frame.pack(); frame.setVisible(true); }
From source file:PanelWithComponents.java
public static void main(String[] a) { JPanel panel = new JPanel(); JButton okButton = new JButton("OK"); panel.add(okButton);//w w w .j a v a 2 s . com JButton cancelButton = new JButton("Cancel"); panel.add(cancelButton); JFrame frame = new JFrame("Oval Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setSize(300, 200); frame.setVisible(true); }
From source file:RelativeY.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.gridx = 0;//from w ww . j a v a2 s .co m pane.add(new JButton("First column"), gbc); gbc.gridx = 1; gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("Second column, first row"), gbc); pane.add(new JButton("Second column, second row"), gbc); pane.add(new JButton("Second column, third row"), gbc); gbc.gridx = 2; pane.add(new JButton("Third column"), gbc); f.setSize(500, 300); f.setVisible(true); }
From source file:Main.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.LINE_END); topPanel.add(text, BorderLayout.CENTER); outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE); frame.add(outerPanel);//from w w w. ja v a 2s . c om frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Fill model final DefaultListModel model = new DefaultListModel(); for (int i = 0, n = labels.length; i < n; i++) { model.addElement(labels[i]);/*from w w w.j ava 2s . com*/ } JList jlist = new JList(model); JScrollPane scrollPane1 = new JScrollPane(jlist); frame.add(scrollPane1, BorderLayout.CENTER); frame.setSize(640, 300); frame.setVisible(true); }
From source file:Main.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.AFTER_LINE_ENDS); frame.add(outerPanel);/* ww w . j a v a 2s . co m*/ frame.setSize(300, 200); frame.setVisible(true); }