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[]) throws ParseException {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = f.getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));

    MaskFormatter mf1 = new MaskFormatter("###-###-###");
    mf1.setPlaceholderCharacter('_');
    JFormattedTextField ftf1 = new JFormattedTextField(mf1);
    content.add(ftf1);/*from  w w  w  .ja v a 2  s .  c  o  m*/

    MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
    JFormattedTextField ftf2 = new JFormattedTextField(mf2);
    content.add(ftf2);
    f.setSize(300, 100);
    f.setVisible(true);
}

From source file:RelativeY.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 = 0;//  w w  w  .j  a v a  2s .  co m
    pane.add(new JButton("First column"), gbc);
    gbc.gridx = 1;
    gbc.gridy = GridBagConstraints.RELATIVE;
    pane.add(new JButton("Second column, first row"), gbc);
    pane.add(new JButton("Second column, second row"), gbc);
    pane.add(new JButton("Second column, third row"), gbc);
    gbc.gridx = 2;
    pane.add(new JButton("Third column"), gbc);
    f.setSize(500, 300);
    f.setVisible(true);
}

From source file:TextLayoutWithCarets.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new TextLayoutWithCarets());
    f.setSize(350, 250);/*w w w  .j a  v  a  2s  .c o m*/
    f.setVisible(true);

}

From source file:GridBagLayoutGridHeight.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();
    pane.add(new JLabel("First row, first column"), gbc);
    pane.add(new JLabel("First row, second column"), gbc);
    gbc.gridheight = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.VERTICAL;
    pane.add(new JLabel("First row, third column"), gbc);
    gbc.gridx = 0;/* ww  w  .  j av  a2 s  .co m*/
    gbc.gridheight = 1;
    gbc.fill = GridBagConstraints.NONE;
    pane.add(new JButton("Second row"), gbc);
    pane.add(new JButton("Third row"), gbc);
    f.setSize(600, 300);
    f.setVisible(true);
}

From source file:MyCanvas.java

public static void main(String args[]) {
    JFrame mainFrame = new JFrame("Graphics demo");
    mainFrame.getContentPane().add(new MyCanvas());
    mainFrame.pack();// w  w  w. j a va2 s . c o m
    mainFrame.setVisible(true);
}

From source file:FontDemo.java

/** Simple main program to start it running */
public static void main(String[] args) {
    JFrame f = new JFrame("Font Demo");
    f.getContentPane().add(new JScrollPane(new FontDemo()));
    f.setSize(600, 700);//from   w w  w .  java 2  s . c  o  m
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:MainClass.java

public static void main(String[] argv) {
    MainClass panel = new MainClass();
    JFrame frame = new JFrame("Arabic Digits");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", panel);
    frame.pack();//from  w ww .j  a va  2s .  c om
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String... args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    Container pane = frame.getContentPane();
    pane.add(blackJTextPane());/*from ww w . j  a v  a  2  s  . c  o m*/
    frame.setSize(800, 600);
    frame.setVisible(true);
}

From source file:GridBagLayoutColumnSpanHORIZONTAL.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;/*from   w w  w.  j av  a  2  s  . c o m*/
    gbc.gridy = GridBagConstraints.RELATIVE;
    pane.add(new JButton("First row, first column"), gbc);
    pane.add(new JButton("Second row"), gbc);
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    pane.add(new JButton("Third row, spans two columns"), gbc);
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = GridBagConstraints.RELATIVE;
    pane.add(new JButton("First row, second column"), gbc);
    f.setSize(400, 300);
    f.setVisible(true);
}

From source file:ScrollBarPieces.java

public static void main(String args[]) {
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    String title = (args.length == 0 ? "ScrollBar Sample" : args[0]);
    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container contentPane = frame.getContentPane();
    contentPane.add(oneJScrollBar, BorderLayout.NORTH);
    frame.setSize(200, 44);//ww w  . ja  va  2s . co  m
    frame.setVisible(true);
}