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:DefaultMutableTreeNodeAddingDemo.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); DefaultMutableTreeNode mercury = new DefaultMutableTreeNode("Mercury"); root.add(mercury);/*w w w . j a va 2s . c o m*/ DefaultMutableTreeNode venus = new DefaultMutableTreeNode("Venus"); root.add(venus); DefaultMutableTreeNode mars = new DefaultMutableTreeNode("Mars"); root.add(mars); JTree tree = new JTree(root); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); DefaultMutableTreeNode mercury = new DefaultMutableTreeNode("Mercury"); root.insert(mercury, 0);//from w w w . ja v a2s .co m DefaultMutableTreeNode venus = new DefaultMutableTreeNode("Venus"); root.insert(venus, 1); DefaultMutableTreeNode mars = new DefaultMutableTreeNode("Mars"); root.insert(mars, 2); JTree tree = new JTree(root); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:TreeRowHeightCache.java
public static void main(String[] argv) { JTree tree = new JTree(); if (tree.getRowHeight() <= 0) { tree.setRowHeight(1);// w w w. java2s . c o m } tree.setRowHeight(0); 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); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setRolloverEnabled(true);/*from ww w. ja v a 2 s . c om*/ jb.setRolloverIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:JPasswordFieldTest.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("JTextField Test"); frame.setLayout(new GridLayout(2, 2)); JLabel label = new JLabel("User Name:", SwingConstants.RIGHT); JLabel label2 = new JLabel("Password:", SwingConstants.RIGHT); JTextField userNameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(); frame.add(label);//from www . j a va 2 s . co m frame.add(userNameField); frame.add(label2); frame.add(passwordField); frame.setSize(200, 70); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.setIcon(new MyIcon()); jb.setIconTextGap(50);//from w ww . j a v a 2 s . c o m JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:TrueTypeJokerman.java
public static void main(String[] args) { JFrame frame = new TrueTypeJokerman(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();//from w w w. ja v a 2s. co m frame.setVisible(true); }
From source file:FancyButton.java
public static void main(String[] args) { FancyButton b1 = new FancyButton(new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif")); FancyButton b2 = new FancyButton(new ImageIcon("4.gif"), new ImageIcon("1.gif"), new ImageIcon("2.gif")); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setLayout(new FlowLayout()); c.add(b1);//from w w w . ja v a 2s. co m c.add(b2); f.pack(); f.setVisible(true); }
From source file:TrueTypeTest.java
public static void main(String[] args) { JFrame frame = new TrueTypeTest(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack();//from w ww. j a v a 2 s.c o m 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(); Container c = frame.getContentPane(); panel.setSize(100, 100);//from w w w.ja v a2s . c om panel.setLayout(new GridLayout(1000, 1)); for (int i = 0; i < 1000; i++) panel.add(new JLabel("JLabel " + i)); JScrollPane jsp = new JScrollPane(panel); c.add(jsp); frame.setSize(100, 100); frame.setVisible(true); }