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 f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Box rowTwo = Box.createHorizontalBox(); AccessibleContext context = rowTwo.getAccessibleContext(); System.out.println(context);//from w w w . j ava2s. c o m rowTwo.add(new JLabel("Password")); rowTwo.add(new JPasswordField()); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200); f.setVisible(true); }
From source file:AdornSample.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 . ja v a2 s. c o m frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Button"); frame.add(button);//from w w w .j a v a2s .co m frame.setAlwaysOnTop(true); frame.setSize(500, 500); frame.setLocation(500, 500); button.addActionListener(e -> { JOptionPane optionPane = new JOptionPane("Option Pane"); optionPane.showMessageDialog(frame, "Message!"); }); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);/* ww w. j a v a 2 s. com*/ frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:GridBagLayoutRemainder.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(); pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("First row, second column"), gbc); pane.add(new JButton("First row, third column"), gbc); gbc.gridx = 0;//from w w w.j av a2 s. c om pane.add(new JButton("Second row"), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Third row, gridwidth set to REMAINDER"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(null);/*from w ww . jav a 2s. co m*/ JButton b1 = new JButton("Button"); JButton b2 = new JButton("2"); contentPane.add(b1); contentPane.add(b2); b1.setBounds(10, 10, 100, 20); b2.setBounds(120, 10, 150, 40); frame.setBounds(0, 0, 350, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = (JPanel) frame.getContentPane(); panel.setLayout(null);//from www .j a v a 2 s. c om JLabel label = new JLabel("aaa"); panel.add(label); Dimension size = label.getPreferredSize(); label.setBounds(100, 100, size.width, size.height); 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.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Table Title", TitledBorder.CENTER, TitledBorder.TOP)); JTable table = new JTable(3, 3); panel.add(new JScrollPane(table)); frame.add(panel);/* ww w. ja v a2s . c o m*/ frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); oneJSlider.setValue(27);// w w w . j a v a 2 s .com int value = oneJSlider.getValue(); System.out.println(value); oneJSlider.setPaintTicks(true); frame.add(oneJSlider, BorderLayout.NORTH); 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); Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "1", "2", "3" }; JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setTableHeader(null);//from www .j a v a2s . co m frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }