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 s[]) {
    JFrame frame = new JFrame("Slider Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.pack();//from   w w  w .  j  a v a2  s  .  c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String argv[]) {
    Main pane = new Main();
    for (int n = 1; n <= 4; n += 1) {
        pane.append(Color.black, String.valueOf(n) + ' ');
    }//from   www.  j a v  a 2s  . c om
    JFrame f = new JFrame("ColorPane example");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new JScrollPane(pane));
    f.setSize(600, 400);
    f.setVisible(true);
}

From source file:CustomTreeCellRenderer.java

public static void main(String[] args) {
    ImageIcon iconWhite = new ImageIcon("white.jpg");
    ImageIcon iconBlack = new ImageIcon("black.jpg");
    ;/* w  w  w  . j a  v  a 2s .co  m*/
    JFrame frame = new JFrame();
    frame.setContentPane(new JPanel(new BorderLayout()));

    JTree tree = new JTree();
    frame.getContentPane().add(tree);

    CustomTreeCellRenderer renderer = new CustomTreeCellRenderer();
    renderer.setRendererIcon(iconWhite);
    tree.setCellRenderer(renderer);

    JPanel panelButtons = new JPanel();

    JButton buttonWhite = new JButton("");
    buttonWhite.setIcon(iconWhite);
    JButton buttonBlack = new JButton("");
    buttonBlack.setIcon(iconBlack);

    buttonBlack.addActionListener(e -> {
        renderer.setRendererIcon(iconBlack);
        tree.repaint();
    });

    panelButtons.add(buttonBlack);
    panelButtons.add(buttonWhite);
    frame.getContentPane().add(panelButtons, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(500, 500);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main(frame));
    frame.pack();//from   ww w  .j av  a 2  s . c o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.validate();/*from   w w  w  .j av  a  2 s.  co m*/
    frame.pack();
    frame.setVisible(true);
}

From source file:DnDBetweenJTextAreaAndJTextFieldDemo.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Drag and Drop Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new JPanel());
    JTextField textField = new JTextField(25);
    textField.setText("www.java2s.com");
    frame.add(textField);/*from   w w w .  j a v a  2  s  .c  om*/

    JTextArea textArea = new JTextArea(4, 25);
    textArea.setText("Demonstrating\ndrag and drop");
    frame.getContentPane().add(new JScrollPane(textArea));
    textArea.setDragEnabled(true);
    textField.setDragEnabled(true);
    frame.pack();
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    Main temp = new Main();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(temp);
    frame.pack();//from ww w. jav  a2s .co  m
    frame.setVisible(true);
    Thread updater = new Thread(temp.new CustomThread());
    updater.start();
}

From source file:Main.java

public static void main(String[] args) {
    JPanel bottomPanel = new JPanel();
    bottomPanel.add(new JButton("Bottom Button"));
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Bottom Panel"));

    JPanel centerPanel = new JPanel();
    centerPanel.setBorder(BorderFactory.createTitledBorder("Center Panel"));

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    mainPanel.add(bottomPanel, BorderLayout.PAGE_END);

    int eb = 25;//from   ww w  .j  ava2  s  . c o  m
    mainPanel.setBorder(BorderFactory.createEmptyBorder(eb, eb, eb, eb));

    mainPanel.setPreferredSize(new Dimension(500, 400));

    JFrame frame = new JFrame("Main");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(mainPanel);
    frame.pack();
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame = new JFrame("List Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.pack();// ww  w.  jav a 2  s.  co m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Scroll Bar Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.setSize(200, 200);//from   w  w w .  j av  a2  s .  c  o m
    frame.setVisible(true);
}