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:GridBagLayoutFill.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 w w . ja v a 2 s.c o m*/ gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("This button's preferred width " + "is large because its text is long"), gbc); pane.add(new JButton("Small centered button"), gbc); gbc.fill = GridBagConstraints.HORIZONTAL; pane.add(new JButton("Expands to fill column width"), gbc); f.setSize(400, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new Main(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack();//from w ww .java 2 s .c om frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JEditorPane htmlPane = new JEditorPane(); String description = "<html><body>Hello<table border=1>" + "<tr><td><img alt='Bad' src='http://www.java2s.com/style/download.png'/></tr></td></table></body></html>"; htmlPane.setContentType("text/html"); htmlPane.setText(description);/*from w w w . j av a 2 s . c o m*/ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JScrollPane(htmlPane)); frame.pack(); frame.setVisible(true); }
From source file:EmptyColumnHeader.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[] = { "", "", "" }; JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150);//w ww. j av a2s . co m frame.setVisible(true); }
From source file:ArabicDigitsI18N.java
public static void main(String[] argv) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add("Center", new ArabicDigitsI18N()); frame.pack();/* w w w.ja va 2 s. co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add("Center", new Main()); frame.pack();//from w w w.j ava 2s . co m frame.setVisible(true); }
From source file:PaneInsertionMethods.java
public static void main(String[] args) { final JTextPane pane = new JTextPane(); pane.replaceSelection("text"); pane.insertIcon(new ImageIcon("imageName.gif")); pane.insertComponent(new JButton("Click Me")); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(pane, BorderLayout.CENTER); frame.setSize(360, 180);/*from w w w .j ava2 s . co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Box rowOne = new Box(BoxLayout.Y_AXIS); rowOne.add(new JLabel("Username")); rowOne.add(Box.createRigidArea(new Dimension(20, 20))); rowOne.add(new JTextField()); Component rowTwo = Box.createVerticalStrut(2); f.add(rowOne, BorderLayout.NORTH); f.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);/* w ww.ja va 2s . com*/ f.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Adornment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 100);/*from www.j ava2 s .co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }/* ww w .j a v a2 s . co m*/ }); jb.setVerticalAlignment(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }