Example usage for javax.swing JFrame setContentPane

List of usage examples for javax.swing JFrame setContentPane

Introduction

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

Prototype

@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.")
public void setContentPane(Container contentPane) 

Source Link

Document

Sets the contentPane property.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setUndecorated(true);// w  w w .ja v a  2s  . c o m
    frame.setBackground(new Color(0, 0, 0, 0));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new ShadowPane());

    JPanel panel = new JPanel(new GridBagLayout());
    panel.add(new JLabel("Look ma, no hands"));

    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(100, 75);/*from w  w  w. j a v  a 2s  .c o m*/
    JPanel content = new JPanel(new FlowLayout());
    frame.setContentPane(content);

    MaskFormatter formatter = new MaskFormatter("#");
    formatter.setValidCharacters("123456789");

    JFormattedTextField f1 = new JFormattedTextField(formatter);
    f1.setValue(null);
    f1.setColumns(1);

    content.add(f1);
    frame.setVisible(true);
}

From source file:FontList.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w w w.ja  v  a 2  s  .c o  m*/
        }
    });
    f.setContentPane(new FontList());
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:MenuElementExample.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Menu Element Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new MenuElementExample());
    frame.setSize(300, 300);/* w w w  .  ja  v a  2  s.  com*/
    frame.setVisible(true);
}

From source file:LiveParenMatcher.java

public static void main(String[] args) {
    JFrame frame = new JFrame("LiveParenMatcher");
    frame.setContentPane(new JScrollPane(new LiveParenMatcher()));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 200);//from   ww  w.ja  v  a 2 s.co  m
    frame.setVisible(true);
}

From source file:FocusTraversalExample.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setFocusTraversalPolicy(new AlphaButtonPolicy());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new FocusTraversalExample());
    frame.setSize(400, 300);/*from w  ww.j ava  2 s  .  c om*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setFocusTraversalPolicy(new AlphaButtonPolicy());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.setSize(400, 300);//from  w  ww  . ja  va  2  s. c o  m
    frame.setVisible(true);
}

From source file:WindowsLookAndFeelDemo.java

public static void main(String[] args) {
    try {//w  ww  .j ava 2  s. co m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    JLabel label = new JLabel("Label");
    JTextField field = new JTextField("www.java2s.com!");
    JList list = new JList(new String[] { "A", "B", "C" });
    JScrollPane listPane = new JScrollPane(list);
    listPane.setPreferredSize(new Dimension(250, 100));

    JScrollPane treePane = new JScrollPane(new JTree());
    treePane.setPreferredSize(new Dimension(250, 100));
    JButton button = new JButton("Click me");

    JPanel cp = new JPanel();
    cp.add(label);
    cp.add(field);
    cp.add(listPane);
    cp.add(treePane);
    cp.add(button);

    JFrame frame = new JFrame();
    frame.setTitle("Windows Look and Feel Demo");
    frame.setPreferredSize(new Dimension(280, 300));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(cp);
    frame.pack();
    frame.setVisible(true);

}

From source file:GTKLookAndFeelDemo.java

public static void main(String[] args) {
    try {// w w w. ja  v  a2s .c om
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    JLabel label = new JLabel("Label");
    JTextField field = new JTextField("www.java2s.com!");
    JList list = new JList(new String[] { "A", "B", "C" });
    JScrollPane listPane = new JScrollPane(list);
    listPane.setPreferredSize(new Dimension(250, 100));

    JScrollPane treePane = new JScrollPane(new JTree());
    treePane.setPreferredSize(new Dimension(250, 100));
    JButton button = new JButton("Click me");

    JPanel cp = new JPanel();
    cp.add(label);
    cp.add(field);
    cp.add(listPane);
    cp.add(treePane);
    cp.add(button);

    JFrame frame = new JFrame();
    frame.setTitle("Windows Look and Feel Demo");
    frame.setPreferredSize(new Dimension(280, 300));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(cp);
    frame.pack();
    frame.setVisible(true);

}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortUtilizationPanel.java

/**
 * Starting point for the demonstration application.
 *
 * @param args/*  w w  w .  j a  v a 2  s.  c  o m*/
 *          ignored.
 */
public static void main(String[] args) {
    JFrame demo = new JFrame("Port Utilization");
    JPanel content = new PortUtilizationPanel();
    demo.setContentPane(content);
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}