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

public static void main(String[] args) {

    final JTextPane pane = new JTextPane();

    pane.replaceSelection("text");
    pane.insertIcon(new ImageIcon("imageName.gif"));
    pane.insertComponent(new JButton("Click Me"));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(pane, BorderLayout.CENTER);
    frame.setSize(360, 180);/*from w w  w  .j a va 2 s  . co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    String HTMLTEXT = "<html><head><style>.foot{color:red} .head{color:black}</style></head>"
            + "<span style='font-family:consolas'>java2s.com</span><br/>"
            + "<span style='font-family:tahoma'>java2s.com</span>";
    JTextPane textPane1 = new JTextPane();

    textPane1.setContentType("text/html");
    textPane1.setText(HTMLTEXT);/*from  w w w.  j  a va 2 s .  c  o m*/

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().add(new JScrollPane(textPane1));
    f.setSize(320, 240);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setSelectedIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();//from  ww w  . j  a  v a2s.c  o m
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");

    jb.setIcon(new MyIcon());
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();// w w w .ja v  a2s  .c  om
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setDisabledIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();/*from  w w w  .  j av a 2  s.  co  m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JToggleButton("Press Me");
    jb.setDisabledSelectedIcon(new MyIcon());

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();//from w  ww  .jav  a 2 s  .  c  om
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Color TRUE_COLOR = new Color(180, 200, 255);
    Color FALSE_COLOR = new Color(255, 100, 100);

    final MyBean panel = new MyBean();
    panel.setTitle(true);/*from  ww w  .  j a  v a  2s  . c o  m*/
    panel.setBackground(TRUE_COLOR);
    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            panel.setTitle(!panel.getTitle());
        }
    });
    panel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(MyBean.TITLE_PROP_NAME)) {
                panel.setBackground(panel.getTitle() ? TRUE_COLOR : FALSE_COLOR);
            }
        }
    });
    JFrame frame = new JFrame();
    frame.getContentPane().add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 300);

    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    String[] headers = { "column 1", "column 2", "column 3", "column 4" };
    int cols = 4;
    int rows = 6;
    String[][] data = new String[rows][cols];
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            data[row][col] = "item " + (row * cols + col + 1);
        }//from  w  w w . ja  v  a2s  . com
    }
    JTable table = new JTable(data, headers);
    DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
    renderer.setHorizontalAlignment(JLabel.RIGHT);
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new JScrollPane(table));
    f.setSize(400, 400);
    f.setLocation(200, 200);
    f.setVisible(true);
}

From source file:Main.java

public static void main(final String[] av) {
    JFrame frame = new JFrame();
    Container cp = frame.getContentPane();
    cp.add(new Main(new File(".")));
    frame.pack();/*from w w  w .  j  a  v a  2  s  .  com*/
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:PaintMethods.java

/** "main program" method - construct and show */
public static void main(String[] av) {
    final JFrame f = new JFrame("PaintMethods demo");
    f.getContentPane().add("Center", new PaintMethods("Testing 1 2 3"));
    f.pack();//from  ww w  .  j av  a  2s  .  com
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}