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:ScrollBarPieces.java
public static void main(String args[]) { JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL); String title = (args.length == 0 ? "ScrollBar Sample" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.add(oneJScrollBar, BorderLayout.NORTH); frame.setSize(200, 44);/*from www. ja va 2 s .c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); }/* ww w .ja va 2s . com*/ }); ItemListener[] lis = jb.getItemListeners(); 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) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from w w w .j ava 2 s . c o m }); jb.setActionCommand("Bob"); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JTree Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); JScrollPane scrollPane = new JScrollPane(tree); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200);//from www .ja v a 2 s. c o m f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }// w w w. j a v a2 s .co m }); ActionListener[] lis = jb.getActionListeners(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:LoadingWebPageToJEditorPane.java
public static void main(String[] a) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane editorPane = new JEditorPane(); editorPane.setPage(new URL("http://www.java2s.com")); frame.add(new JScrollPane(editorPane)); frame.setSize(300, 200);//from w w w . j a va 2s .c om 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 pnl = new JPanel(); pnl.add(new MyButton()); frame.add(pnl);//w ww . j a v a 2 s. com frame.setSize(600, 600); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Main()); f.pack();/*from w w w .ja va2 s.c o m*/ f.setSize(400, 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); Vector<String> data = new Vector<String>(); for (int i = 1; i < 100; i++) { data.add("Entry " + i); }/*from w w w .j a v a 2s .c o m*/ JList<String> list = new JList<>(data); list.setVisibleRowCount(8); JScrollPane scrollPane = new JScrollPane(list); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }
From source file:TreeSelectionOption.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);//from w ww .jav a 2 s. c o m frame.setLocationRelativeTo(null); frame.setVisible(true); }