Example usage for javax.swing JFrame getContentPane

List of usage examples for javax.swing JFrame getContentPane

Introduction

In this page you can find the example usage for javax.swing JFrame getContentPane.

Prototype

public Container getContentPane() 

Source Link

Document

Returns the contentPane object for this frame.

Usage

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setSelected(true);/*  w  ww. ja  va2  s.c  o m*/
    System.out.println(jb.getVerticalAlignment());

    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[] args) {
    AbstractButton jb = new JButton("Press Me");
    jb.setMargin(new Insets(5, 5, 5, 5));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();/*from w w w.  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.setSelected(true);/*from   www .  j a v a2s . c  o  m*/
    System.out.println(jb.getIconTextGap());

    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[] args) throws Exception {
    final MaskFormatter formatter = new TimeFormatter();
    formatter.setValueClass(java.util.Date.class);
    final JFormattedTextField tf2 = new JFormattedTextField(formatter);
    tf2.setValue(new Date());
    final JLabel label = new JLabel();
    JButton bt = new JButton("Show Value");
    bt.addActionListener(e -> {/*from  ww  w  .  java  2 s  .  c  om*/
        System.out.println(" value 2 = " + tf2.getValue());
        System.out.println(" value 2 = " + tf2.getText());
        System.out.println("value class: " + formatter.getValueClass());
        label.setText(tf2.getText());
    });
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new GridLayout());
    f.getContentPane().add(tf2);
    f.getContentPane().add(label);
    f.getContentPane().add(bt);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}

From source file:SpringFormTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Spring");
    Container contentPane = frame.getContentPane();

    SpringLayout layout = new SpringLayout();
    contentPane.setLayout(layout);/*from   w  w  w . j a  v a 2 s.c  o m*/

    Component left = new JLabel("Left");
    Component right = new JTextField(15);

    contentPane.add(left);
    contentPane.add(right);

    layout.putConstraint(SpringLayout.WEST, left, 10, SpringLayout.WEST, contentPane);
    layout.putConstraint(SpringLayout.NORTH, left, 25, SpringLayout.NORTH, contentPane);
    layout.putConstraint(SpringLayout.NORTH, right, 25, SpringLayout.NORTH, contentPane);
    layout.putConstraint(SpringLayout.WEST, right, 20, SpringLayout.EAST, left);

    frame.setSize(300, 100);
    frame.show();
}

From source file:Highlights.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new Highlights());
    f.setSize(850, 250);/*from  www  .  j a  va2  s . c  o  m*/
    f.show();

}

From source file:Main.java

public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            JScrollPane scrollpane = new JScrollPane(new ScrollPaneArtifacts());
            scrollpane.getViewport().setPreferredSize(new Dimension(400, 400));
            JFrame frame = new JFrame("ScrollPaneArtifacts");
            frame.getContentPane().add(scrollpane);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();//w w  w. j  a  v a2 s . c  o  m
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
}

From source file:RedBlueBox.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));
    JComponent comp = new RedBlueBox();
    comp.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.PINK));
    contentPane.add(comp);//from   w w w .ja  v a 2  s.  c  om
    comp = new RedBlueBox();
    contentPane.add(comp);
    frame.setSize(300, 200);
    frame.show();
}

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  ww .  j av  a  2 s  .  c om

    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);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(getPanel());
    f.pack();//from   w w  w. j av  a  2s  . c  om
    f.setVisible(true);
}