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("MouseWheelEventDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComponent newContentPane = new Main();
    newContentPane.setOpaque(true);//from  w w w.  j  a v  a 2 s.c o  m
    frame.setContentPane(newContentPane);

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

From source file:AntiAlias.java

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

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();
    JLabel label = new JLabel("Label with image in Tooltip!");
    label.setToolTipText("<html><img src=\"" + Main.class.getResource("tooltip.gif") + "\"> Tooltip ");
    label.setHorizontalAlignment(JLabel.CENTER);
    frame.setContentPane(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(100, 100, 200, 100);
    frame.setVisible(true);/*from w ww.ja  v a  2  s  . co  m*/

}

From source file:MainClass.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Combo Box Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new MainClass());
    frame.pack();/*  w w  w. j  av a  2 s  .co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Combo Box Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.pack();/*from  w  w w  .j  av  a  2  s  .com*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Main newContentPane = new Main();
    newContentPane.setOpaque(true);/* w  w w .  j  a  v a 2s. c  om*/
    f.setContentPane(newContentPane);

    f.pack();
    f.setVisible(true);
}

From source file:jmemorize.gui.swing.panels.HistoryChartPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setContentPane(new HistoryChartPanel(new LearnHistory(Main.STATS_FILE)));
    frame.setSize(new Dimension(800, 800));
    frame.setVisible(true);//w  ww  . java 2s  . c o m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public static void main(String[] args) {
    int nb = 4;/* w w  w .j  av a  2s.c  o  m*/
    final int frameCount = nb;

    for (int i = 0; i < frameCount; i++) {
        JFrame frame = new JFrame("Frame number " + i);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        JPanel p = new JPanel(new BorderLayout());
        p.add(new JLabel("Click on the corner to close..."), BorderLayout.CENTER);
        frame.setContentPane(p);
        frame.setSize(200, 200);
        frame.setLocation(100 + 20 * i, 100 + 20 * i);
        frame.setVisible(true);
    }
}

From source file:CombinationFormatter.java

public static void main(String argv[]) {
    // a demo main() to show how CombinationFormatter could be used
    int comb1[] = { 35, 11, 19 };
    int comb2[] = { 10, 20, 30 };

    final JFormattedTextField field1 = new JFormattedTextField(new CombinationFormatter());
    field1.setValue(comb1);/* ww  w . j  a va2 s . c  o  m*/

    final JFormattedTextField field2 = new JFormattedTextField(new CombinationFormatter());
    field2.setValue(comb2);

    JPanel pan = new JPanel();
    pan.add(new JLabel("Change the combination from"));
    pan.add(field1);
    pan.add(new JLabel("to"));
    pan.add(field2);

    JButton b = new JButton("Submit");
    b.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent ae) {
            try {
                field1.commitEdit(); // make sure current edit (if any) gets
                // committed
                field2.commitEdit();
            } catch (java.text.ParseException pe) {
            }
            int oldc[] = (int[]) field1.getValue();
            int newc[] = (int[]) field2.getValue();
            //
            // code to validate oldc[] and change to newc[] goes here
            //
        }
    });
    pan.add(b);

    JFrame f = new JFrame("CombinationFormatter Demo");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(pan);
    f.setSize(360, 100);
    f.setVisible(true);
}

From source file:BoxLayoutPane.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from   ww  w.jav  a2 s  .  c o  m*/
        }
    });

    f.setContentPane(new BoxLayoutPane());
    f.pack();
    f.setVisible(true);
}