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:layout.SpringGrid.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./* www.  j  a  v  a  2  s .com*/
 */
private static void createAndShowGUI() {
    //Create the panel and populate it.
    JPanel panel = new JPanel(new SpringLayout());
    for (int i = 0; i < 9; i++) {
        JTextField textField = new JTextField(Integer.toString(i));

        //Make the 4th field extra big.
        if (i == 4) {
            textField.setText("This one is extra long.");
        }

        panel.add(textField);
    }

    //Lay out the panel.
    SpringUtilities.makeGrid(panel, 3, 3, //rows, cols
            5, 5, //initialX, initialY
            5, 5);//xPad, yPad

    //Create and set up the window.
    JFrame frame = new JFrame("SpringGrid");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Set up the content pane.
    panel.setOpaque(true); //content panes must be opaque
    frame.setContentPane(panel);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:CheckThreadViolationRepaintManager.java

static void imageUpdateTest() {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JEditorPane editor = new JEditorPane();
    frame.setContentPane(editor);
    editor.setContentType("text/html");
    // it works with no valid image as well
    editor.setText("<html><img src=\"file:\\lala.png\"></html>");
    frame.setSize(300, 200);//w ww.  j av a2 s .  c  om
    frame.setVisible(true);
}

From source file:QandE.Layout1.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./* w  w  w. j  a va 2  s.co  m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Layout1");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add the innards.
    JPanel p = new JPanel(new BorderLayout());
    p.add(createComponent("Component 1"), BorderLayout.CENTER);
    frame.setContentPane(p);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:ButtonDemo.java

private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);

    JFrame frame = new JFrame("ButtonDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ButtonDemo newContentPane = new ButtonDemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    frame.pack();// w  w w. j a  v  a  2  s . co  m
    frame.setVisible(true);
}

From source file:QandE.LunarPhasesRB.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from  ww w.  ja v  a  2s  .c o  m
 */
private static void createAndShowGUI() {
    //Create a new instance of LunarPhasesRB.
    LunarPhasesRB phases = new LunarPhasesRB();

    //Create and set up the window.
    JFrame lunarPhasesFrame = new JFrame("Lunar Phases");
    lunarPhasesFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    lunarPhasesFrame.setContentPane(phases.mainPanel);

    //Display the window.
    lunarPhasesFrame.pack();
    lunarPhasesFrame.setVisible(true);
}

From source file:customprogressindicatordemo.Main.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./*from  w w  w  .j  av  a2  s .  com*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Weather Application");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    WeatherData newContentPane = new WeatherData();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:events.Beeper.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./* w  w w .  j  a  v a  2  s  . co m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Beeper");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new Beeper();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Interface.Stats.java

/**
* Sous programme permettant de vrifier que chaque 
* fentre n'est cre qu'une fois puis uniquement rutilise
* @param f//w w w  .  j a  v a 2  s  .co  m
* @return type de la classe
*/
public static Stats getFenetre(JFrame f) {

    if (fenetre == null) {
        fenetre = new Stats(f);
    }

    f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background
    f.add(p1);
    f.add(p2);
    f.add(p4);

    f.setVisible(true);
    f.setSize(new Dimension(600, 600));

    return fenetre;
}

From source file:Beeper.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from  ww w.  ja va2 s. c  o m
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("Beeper");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new Beeper();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:QandE.Beeper1.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./* ww w . j a v  a 2  s .  com*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Beeper2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    JComponent newContentPane = new Beeper1();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}