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:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Sharing Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); JTextArea textarea1 = new JTextArea(); Document document = textarea1.getDocument(); JTextArea textarea2 = new JTextArea(document); JTextArea textarea3 = new JTextArea(document); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(new JScrollPane(textarea1)); content.add(new JScrollPane(textarea2)); content.add(new JScrollPane(textarea3)); frame.setSize(300, 400);//from ww w. ja va 2 s. co m frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from w w w . ja v a2 s. c o m*/ JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); frame.setSize(300, 350); frame.setVisible(true); }
From source file:TreeNodeRemove.java
public static void main(String[] argv) { Vector<String> v = new Vector<String>(); v.add("a");//from w ww .j a v a 2 s .c o m v.add("b"); v.add("c"); JTree tree = new JTree(v); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); int startRow = 0; String prefix = "b"; TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Forward); MutableTreeNode node = (MutableTreeNode) path.getLastPathComponent(); model.removeNodeFromParent(node); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:JScrollPaneViewport.java
public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Label"); label.setPreferredSize(new Dimension(1000, 1000)); JScrollPane jScrollPane = new JScrollPane(); jScrollPane.setViewportView(label);// w w w. ja v a2 s . com frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Line Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border thinBorder = LineBorder.createBlackLineBorder(); JButton thinButton = new JButton("1 Pixel"); thinButton.setBorder(thinBorder);/*w ww . java2s . c om*/ Container contentPane = frame.getContentPane(); contentPane.add(thinButton, BorderLayout.NORTH); frame.pack(); frame.setSize(300, frame.getHeight()); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from www .ja v a2 s.c om*/ JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectedIndex(1); frame.setSize(300, 350); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border softBevelBorder = new SoftBevelBorder(BevelBorder.RAISED, Color.RED, Color.RED.darker(), Color.PINK, Color.PINK.brighter()); JLabel aLabel = new JLabel("Bevel"); aLabel.setBorder(softBevelBorder);// www .j av a 2 s .co m aLabel.setHorizontalAlignment(JLabel.CENTER); frame.add(aLabel); frame.setSize(400, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(labels); jlist1.setVisibleRowCount(4);/*from ww w .j a v a 2 s .c o m*/ JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.setSelectionBackground(Color.RED); frame.setSize(300, 350); frame.setVisible(true); }
From source file:LabelFor.java
public static void main(String args[]) { JFrame f = new JFrame("LabelFor Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); JLabel label = new JLabel("Username"); JTextField textField = new JTextField(); label.setDisplayedMnemonic(KeyEvent.VK_U); label.setLabelFor(textField);/*from w ww.ja v a2 s .c o m*/ Container box = Box.createHorizontalBox(); box.add(label); box.add(textField); content.add(box, BorderLayout.NORTH); content.add(new JButton("Submit"), BorderLayout.SOUTH); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame parent = new JFrame(); parent.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); parent.setSize(300, 300);//from w w w . ja v a 2 s . c om parent.setVisible(true); Main dlg = new Main(parent); dlg.setVisible(true); }