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:ImageView.java

public static void main(String[] arg) {
    if (arg.length == 0) {
        System.err.println("Usage: ImageView file [...]");
    } else {/*from   w  w  w  .  j ava 2s . c  o  m*/
        for (int i = 0; i < arg.length; i++) {
            JFrame jf = new JFrame("ImageView: " + arg[i]);
            ImageView iv = new ImageView(arg[i]);
            jf.getContentPane().add(iv);
            iv.loadImage();
            jf.setSize(iv.getSize());
            jf.setVisible(true);
        }
    }
}

From source file:CutPasteSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Cut/Paste Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = frame.getContentPane();

    JTextField textField = new JTextField();
    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);

    content.add(textField, BorderLayout.NORTH);
    content.add(scrollPane, BorderLayout.CENTER);

    Action actions[] = textField.getActions();

    Action cutAction = TextUtilities.findAction(actions, DefaultEditorKit.cutAction);
    Action copyAction = TextUtilities.findAction(actions, DefaultEditorKit.copyAction);
    Action pasteAction = TextUtilities.findAction(actions, DefaultEditorKit.pasteAction);

    JPanel panel = new JPanel();
    content.add(panel, BorderLayout.SOUTH);

    JButton cutButton = new JButton(cutAction);
    cutButton.setText("Cut");
    panel.add(cutButton);//from   www  . jav  a2  s  . c  o m

    JButton copyButton = new JButton(copyAction);
    copyButton.setText("Copy");
    panel.add(copyButton);

    JButton pasteButton = new JButton(pasteAction);
    pasteButton.setText("Paste");
    panel.add(pasteButton);

    frame.setSize(250, 250);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.add(new SpringLayoutPanel());
    aWindow.setVisible(true);// w w  w  .j  av  a  2 s .  c o  m
}

From source file:com.google.code.facebook.graph.sna.applet.ImageEdgeLabelDemo.java

/**
* a driver for this demo/*from   w w  w.ja  va2 s.c o  m*/
*/
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new ImageEdgeLabelDemo());
    frame.pack();
    frame.setVisible(true);
}

From source file:GetImage.java

public static void main(String[] args) {
    JFrame f = new JFrame("GetImage");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GetImage myApplet = new GetImage();
    f.getContentPane().add(myApplet);
    myApplet.init();//from   w w w.  j  a  v a2s.  c  om
    f.setSize(100, 100);
    f.setVisible(true);
    myApplet.start();
}

From source file:MainClass.java

public static void main(String[] av) {
    JFrame frame = new JFrame("MainClass");
    frame.setForeground(Color.black);
    frame.setBackground(Color.lightGray);
    Container cp = frame.getContentPane();
    cp.add(new MainClass(new File(".")));

    frame.pack();//from ww  w  .j a  v  a2s .c om
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public static void main(String s[]) {
    Main example = new Main();
    example.pane = new JTextPane();
    example.pane.setPreferredSize(new Dimension(250, 250));
    example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(example.menuBar);//from  ww w  .j a v  a 2 s  .  co  m
    frame.getContentPane().add(example.pane, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}

From source file:LabelForComboBox.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//  www. j ava2s  .c  o  m
        }
    });
    f.getContentPane().add(new LabelForComboBox());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container content = aWindow.getContentPane();
    content.add(new GridBagLayoutPanel());
    aWindow.setVisible(true);/*www.  j av  a  2 s  .co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    Main mainPanel = new Main(frame);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(mainPanel);
    frame.pack();//ww w.  ja  va  2  s .  co  m
    frame.setVisible(true);
}