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) { AbstractButton jb = new JToggleButton("Press Me"); jb.setRolloverEnabled(true);/*from w w w . jav a 2 s .co m*/ jb.setRolloverIcon(new MyIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:OffsetSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Offset Example"); Container content = frame.getContentPane(); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); final JTextField textField = new JTextField(); label.setLabelFor(textField);//from w w w .j a v a 2 s. c o m panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); content.add(panel, BorderLayout.NORTH); JButton button = new JButton("Get Offset"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Offset: " + textField.getScrollOffset()); System.out.println("Visibility: " + textField.getHorizontalVisibility()); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); } }; button.addActionListener(actionListener); content.add(button, BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.setIcon(new MyIcon()); jb.setIconTextGap(50);/*w ww.j a va 2 s . co m*/ JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:AlignX.java
public static void main(String args[]) { JFrame frame = new JFrame("X Alignment"); Container contentPane = frame.getContentPane(); Container panel1 = makeIt("R", Component.RIGHT_ALIGNMENT); Container panel2 = makeIt("C", Component.CENTER_ALIGNMENT); Container panel3 = makeIt("L", Component.LEFT_ALIGNMENT); contentPane.setLayout(new FlowLayout()); contentPane.add(panel1);// ww w . j av a 2s .c o m contentPane.add(panel2); contentPane.add(panel3); frame.pack(); frame.show(); }
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); f.pack();// w ww. j a v a 2s . c o m f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setHorizontalTextPosition(20);/* w ww. j ava 2 s . c o m*/ 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[] argv) throws Exception { JFrame frame = new JFrame(); Container container = frame.getContentPane(); GridBagLayout gbl = new GridBagLayout(); container.setLayout(gbl);//from w w w.j a v a 2 s.co m GridBagConstraints gbc = new GridBagConstraints(); JButton component1 = new JButton("a"); JButton component2 = new JButton("b"); gbc.gridx = 1; gbc.gridy = 1; gbl.setConstraints(component1, gbc); container.add(component1); gbc.gridx = 0; gbc.gridy = 0; gbl.setConstraints(component2, gbc); container.add(component2); container.add(component1); container.add(component2); frame.pack(); frame.setVisible(true); gbl.layoutContainer(container); int[][] dim = gbl.getLayoutDimensions(); int cols = dim[0].length; int rows = dim[1].length; System.out.println(cols); System.out.println(rows); }
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); f.pack();/* www. j ava 2 s . c o m*/ f.setVisible(true); }
From source file:FocusCycleSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Focus Cycle Sample"); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 3)); for (int i = 0; i < 8; i++) { JButton button = new JButton("" + i); contentPane.add(button);/*from ww w . jav a 2s. co m*/ } JPanel panel = new FocusCycleConstrainedJPanel(); panel.setLayout(new GridLayout(1, 3)); for (int i = 0; i < 3; i++) { JButton button = new JButton("" + (i + 3)); panel.add(button); } contentPane.add(panel); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ShowImage.java
static public void main(String args[]) throws Exception { JFrame frame = new JFrame("ShowImage.java"); Panel panel = new ShowImage(args[0]); frame.getContentPane().add(panel); frame.setSize(400, 400);/*from w ww .j a v a 2 s. com*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }