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) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }/* ww w . j ava2 s . c o m*/ }); jb.setText("new text"); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); 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); JTable table = new JTable(4, 5); // 4 rows & 5 columns table.setRowSelectionAllowed(false); table.setColumnSelectionAllowed(false); table.setCellSelectionEnabled(false); frame.add(new JScrollPane(table)); frame.setSize(300, 200);//from www.j a v a 2s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String htmlLabel = "<html><sup>HTML</sup> <sub><em>Label</em></sub><br>" + "<font color=\"#FF0080\"><u>Multi-line</u></font>"; JLabel label = new JLabel(htmlLabel); System.out.println(label.getText()); frame.add(label);//from w ww. ja v a2s . c o m frame.setSize(300, 200); 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!"); }/*w w w .j a v a 2 s .c o m*/ }); jb.setVerticalTextPosition(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button1 = new JButton("Text Button"); button1.setMnemonic(KeyEvent.VK_B); frame.add(button1);/*from w w w.java 2s .co m*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:RelativeXY.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 = 1;//from w ww . j a v a2 s. co m gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(500, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new Main(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();//from w w w . j a va 2s .co m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String title = "GridBagLayout"; JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridBagLayout()); for (int i = 1; i <= 9; i++) { contentPane.add(new JButton("Button " + i)); }/*from ww w. j av a 2 s .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); JTextPane newsTextPane = new JTextPane(); newsTextPane.setEditable(false);//w w w.ja v a 2 s.c o m JScrollPane scrollPane = new JScrollPane(newsTextPane); frame.add(scrollPane); frame.setSize(300, 250); frame.setVisible(true); System.out.println("Height : " + scrollPane.getViewport().getSize().height + "\nWidth :" + scrollPane.getViewport().getSize().width); }
From source file:TreeRowHeight15.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(15);//from ww w. j a v a 2 s . c o m JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }