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 JToggleButton("Press Me"); jb.setPressedIcon(new MyIcon()); System.out.println(jb.getPressedIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);// w w w .jav a 2s. c om f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setHorizontalTextPosition(20);/*w w w .j a v a2 s.com*/ jb.setIcon(new MyIcon()); 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 JToggleButton("Press Me"); jb.setHorizontalAlignment(SwingConstants.RIGHT); jb.setIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w w w.j av a 2s . c o m*/ f.pack(); f.setVisible(true); }
From source file:BoundedRangeModelInJSlider.java
public static void main(String args[]) { JFrame frame = new JFrame("Tick Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); System.out.println(oneJSlider.getModel().getMaximum()); frame.add(oneJSlider, BorderLayout.NORTH); frame.setSize(300, 200);//w w w . j ava 2s. c om frame.setVisible(true); }
From source file:ABevelBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = BorderFactory.createRaisedBevelBorder(); JButton button = new JButton("Raised"); button.setBorder(raisedBorder);//from ww w .ja va 2 s . com frame.add(button); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField nameTextField = new JTextField(); JLabel nameLabel = new JLabel("Name:"); nameLabel.setDisplayedMnemonic('N'); nameLabel.setLabelFor(nameTextField); frame.add(nameLabel, BorderLayout.WEST); frame.add(nameTextField, BorderLayout.CENTER); frame.pack();/* w w w . j a v a 2 s . c o m*/ frame.setVisible(true); }
From source file:TreeEditJCheckBox.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Properties props = System.getProperties(); JTree tree = new JTree(props); JCheckBox checkBox = new JCheckBox("To be or not to be"); TreeCellEditor editor = new DefaultCellEditor(checkBox); tree.setEditable(true);/*from www . j ava 2 s . c o m*/ tree.setCellEditor(editor); 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) { final JTextPane textPane = new JTextPane(); final JScrollPane scrollPane = new JScrollPane(textPane); String text = "Lorem ipsum dolor sit amet, " + "consectetur adipiscing elit." + "Fusce nec sapien id diam consequat adipiscing."; textPane.setText(text);//www. ja v a 2s. c om JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(scrollPane); frame.setSize(new Dimension(200, 200)); frame.setVisible(true); FontMetrics metrics = textPane.getFontMetrics(textPane.getFont()); textPane.setMargin(new Insets(scrollPane.getViewport().getHeight() - metrics.getHeight(), 0, 0, 0)); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); f.getContentPane().add(new Main().makeUI()); f.setSize(320, 320);/*from w ww.j ava2s . c o m*/ f.setVisible(true); }
From source file:TreeEditJTextField.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Properties props = System.getProperties(); JTree tree = new JTree(props); JTextField textField = new JTextField(); TreeCellEditor editor = new DefaultCellEditor(textField); tree.setEditable(true);// www .j a v a 2s . c o m tree.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }