List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:Main.java
public static void main(String args[]) { JPanel p = new JPanel(); p.setLayout(new GridLayout(2, 1)); JList<String> lista = new JList<>(new String[] { "1", "2", "3", "4" }); p.add(new JScrollPane(lista)); JComboBox<String> combo = new JComboBox<>(); for (int i = 0; i < 100; i++) { combo.addItem(Integer.toString(i)); p.add(combo);/*from w w w.java 2 s . c o m*/ } JFrame f = new JFrame(); f.getContentPane().add(p, BorderLayout.CENTER); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200, 200); f.setVisible(true); }
From source file:IteratorTest.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new IteratorTest()); f.setSize(850, 250);//w ww . j av a2 s. c o m f.show(); }
From source file:Main.java
public static void main(String[] args) { JTable table = new JTable(5, 5) { @Override/*from ww w . j a v a 2s . com*/ public Component prepareRenderer(TableCellRenderer renderer, int row, int col) { Component comp = super.prepareRenderer(renderer, row, col); ((JLabel) comp).setHorizontalAlignment(JLabel.RIGHT); return comp; } }; table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane(table); JFrame f = new JFrame(); f.getContentPane().add(scrollPane); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JComboBox<String> box = new JComboBox<>(); box.addItem("One"); box.addItem("Two"); box.addItem("Three"); box.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { System.out.println(e.getItem()); }//from w w w.j av a 2 s .co m } }); JFrame frame = new JFrame(); frame.getContentPane().add(box); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200);/*w w w.j a v a2 s . com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { boolean resizable = true; boolean closeable = true; boolean maximizable = true; boolean iconifiable = true; String title = "Frame Title"; JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable); iframe.setSize(300, 300);/*from w w w. j av a 2 s.c o m*/ iframe.setVisible(true); iframe.getContentPane().add(new JTextArea()); JDesktopPane desktop = new JDesktopPane(); desktop.add(iframe); JFrame frame = new JFrame(); frame.getContentPane().add(desktop, BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTabbedPane tabbedPane = new JTabbedPane(); for (int i = 0; i < 5; i++) { tabbedPane.add("Tab " + i, new JLabel("Label " + i, SwingConstants.CENTER)); }//from w w w . j a va2 s . c om tabbedPane.getModel().addChangeListener(e -> { JLabel label = (JLabel) tabbedPane.getSelectedComponent(); System.out.println(label.getText()); }); tabbedPane.setPreferredSize(new Dimension(500, 300)); JFrame frame = new JFrame(); frame.getContentPane().add(tabbedPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:TextRendering.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new TextRendering()); f.setSize(800, 800);/*from w w w .ja v a 2 s .c om*/ f.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400);/*from ww w. j a va 2 s . co m*/ frame.setVisible(true); }
From source file:ImageTest.java
public static void main(String[] args) { JPanel panel = new JPanel(); ImageLabel label = new ImageLabel(new ImageIcon("images/reactor.png")); label.setLocation(29, 37);//from ww w . j a v a 2s . co m panel.add(label); JFrame frame = new JFrame(); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); }