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[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); Icon icon = new ImageIcon("java2s.gif"); JButton b = new JButton(icon); JScrollPane pane = new JScrollPane(b); AdjustmentListener hListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Horizontal: "); dumpInfo(e);//from ww w . j a v a 2s .co m } }; JScrollBar hBar = pane.getHorizontalScrollBar(); hBar.addAdjustmentListener(hListener); AdjustmentListener vListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Vertical: "); dumpInfo(e); } }; JScrollBar vBar = pane.getVerticalScrollBar(); vBar.addAdjustmentListener(vListener); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
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 w w .j a v a2 s . c om f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String[] items = { "A", "B", "C" }; JComboBox<String> comboBox1 = new MyComboBox1<>(items); JPanel p = new JPanel(); p.add(comboBox1);/*w w w.jav a 2 s. c om*/ JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(p); f.setSize(320, 240); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { int MAX_CELLS = 30; DefaultListModel<String> listModel = new DefaultListModel<>(); JList<String> myList = new JList<>(listModel); myList.setVisibleRowCount(8);// w w w. j a va2 s . c om for (int i = 0; i < MAX_CELLS; i++) { listModel.addElement("label " + i); } JTabbedPane jTabbedPane = new JTabbedPane(); jTabbedPane.add("Test", new JScrollPane(myList)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(jTabbedPane); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); MyTextArea txt = new MyTextArea(); f.getContentPane().add(txt); f.getContentPane().add(new JButton("OK"), BorderLayout.SOUTH); f.pack();//from w w w . j a v a2 s. c om f.setVisible(true); }
From source file:AdjustmentTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); Icon icon = new ImageIcon("java2s.gif"); JButton b = new JButton(icon); JScrollPane pane = new JScrollPane(b); AdjustmentListener hListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Horizontal: "); dumpInfo(e);/* w ww . j a va 2s . co m*/ } }; JScrollBar hBar = pane.getHorizontalScrollBar(); hBar.addAdjustmentListener(hListener); AdjustmentListener vListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { System.out.println("Vertical: "); dumpInfo(e); } }; JScrollBar vBar = pane.getVerticalScrollBar(); vBar.addAdjustmentListener(vListener); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); JPanel a = new JPanel(); a.setAlignmentX(Component.CENTER_ALIGNMENT); a.setPreferredSize(new Dimension(100, 100)); a.setMaximumSize(new Dimension(100, 100)); // set max = pref a.setBorder(BorderFactory.createTitledBorder("aa")); JPanel b = new JPanel(); b.setAlignmentX(Component.CENTER_ALIGNMENT); b.setPreferredSize(new Dimension(50, 50)); b.setMaximumSize(new Dimension(50, 50)); // set max = pref b.setBorder(BorderFactory.createTitledBorder("bb")); frame.getContentPane().add(a);//from w ww .j a va 2 s .c om frame.getContentPane().add(b); frame.pack(); frame.setVisible(true); }
From source file:RelativeXY.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1;/* w w w . ja v a 2 s. c om*/ gbc.gridy = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, first column"), gbc); pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); gbc.gridx = GridBagConstraints.RELATIVE; pane.add(new JButton("First row, second column"), gbc); f.setSize(500, 300); f.setVisible(true); }
From source file:RoundGradientPaintFill.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new RoundGradientPaintFill()); f.setSize(200, 200);/* ww w . ja v a2s. c om*/ f.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = (JPanel) frame.getContentPane(); panel.setLayout(new BorderLayout()); JTextField field = new JTextField(20); Main spinner = new Main(); panel.add(field, "Center"); panel.add(spinner, "East"); Dimension dim = frame.getToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getWidth() / 2, dim.height / 2 - frame.getHeight() / 2); frame.pack();/*w w w . j a v a 2s .co m*/ frame.show(); }