List of usage examples for javax.swing JFrame add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i);/*from w w w .j av a2s . c o m*/ } f.add(new JScrollPane(tree)); f.pack(); f.setSize(200, 200); f.setVisible(true); }
From source file:MyComboBoxModel.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox cbox = new JComboBox(new MyComboBoxModel()); cbox.setMaximumRowCount(5);//w w w. ja v a2 s . c o m frame.add(cbox); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ActionListenerTest2.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Select File"); button.addActionListener(new MyActionListener()); frame.add(button); frame.pack();/*from w ww .ja v a2 s . co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("java2s.com"); label.setEnabled(false);//from w w w . ja v a 2 s. c om f.add(label); f.pack(); f.setVisible(true); }
From source file:UIDefaultsButton.java
License:asdf
public static void main(String[] args) { UIManager.put("Button.background", Color.BLACK); UIManager.put("Button.foreground", Color.RED); JFrame aWindow = new JFrame("This is a Border Layout"); aWindow.setBounds(30, 30, 300, 300); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bn = new JButton("asdf"); aWindow.add(bn); aWindow.setVisible(true); // Display the window }
From source file:MonthPanel.java
public static void main(String[] args) { MonthPanel panel = new MonthPanel(5, 2015); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new FlowLayout()); frame.add(panel); frame.pack();/*w w w . j a v a2 s . co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane jep = new JEditorPane(); jep.setText("Hello to the public"); frame.add(jep); frame.pack();/*from w ww . ja v a 2s . co m*/ frame.setVisible(true); highlight(jep, "public"); }
From source file:Main.java
public static void main(String[] args) { Container c1 = new GradientPanel(); Container c2 = new GradientPanel(); JTabbedPane top = new JTabbedPane(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); top = new JTabbedPane(JTabbedPane.TOP); top.addTab("1", c1); top.addTab("2", c2); frame.add(top); frame.pack();/*from w w w .jav a 2s . co m*/ frame.setVisible(true); }
From source file:Main.java
public static final void main(String args[]) throws Exception { JFrame f = new JFrame(); DefaultListModel<String> dlm = new DefaultListModel<String>(); JList<String> list = new JList<>(dlm); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new JScrollPane(list)); f.add(new JButton("Add") { {/*from w w w. ja va 2s . co m*/ addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dlm.addElement("A"); } }); } }, BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
From source file:ActionChangedListener.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bn = new JButton(); bn.addPropertyChangeListener(new ActionChangedListener(bn)); frame.add(bn); bn.setEnabled(false);/* w ww. ja v a 2 s .c om*/ frame.setSize(300, 300); frame.setVisible(true); frame.add(bn); }