Example usage for javax.swing JFrame getRootPane

List of usage examples for javax.swing JFrame getRootPane

Introduction

In this page you can find the example usage for javax.swing JFrame getRootPane.

Prototype

@BeanProperty(bound = false, hidden = true, description = "the RootPane object for this frame.")
public JRootPane getRootPane() 

Source Link

Document

Returns the rootPane object for this frame.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JRootPane root = f.getRootPane();
    Container content = root.getContentPane();
    content.add(new JButton("Hello"));
    f.pack();/*from ww w  .j a va 2  s  .  com*/
    f.setVisible(true);
}

From source file:RootExample.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JRootPane root = f.getRootPane(); // XXX Pay attention to these
    Container content = root.getContentPane(); // XXX lines. They get more
    content.add(new JButton("Hello")); // XXX explanation in the book.
    f.pack();/*from w  w  w.  ja  v a  2 s.  c o m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JRootPane root = f.getRootPane();
    Container content = root.getContentPane();
    content.add(new JButton("Hello"));

    f.pack();/*  w w  w.j a v a  2s  .c  om*/
    f.setVisible(true);

}

From source file:RootExample2.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JRootPane root = f.getRootPane();

    // Create a menu bar
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    bar.add(menu);//from w w  w.  j a va2  s . com
    menu.add("Open");
    menu.add("Close");
    root.setJMenuBar(bar);

    // Add a button to the content pane
    root.getContentPane().add(new JButton("Hello World"));

    // Display the UI
    f.pack();
    f.setVisible(true);
}

From source file:AdornSample.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Adornment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setUndecorated(true);//w ww .j  av a2 s .  c  o  m
    frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Adornment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setUndecorated(true);/*w w  w  .  j a va2s.c om*/
    frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    frame.setSize(300, 100);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String args[]) {
    JButton jbtnA = new JButton("java2s.com");

    JFrame jfrm = new JFrame();
    jfrm.setSize(300, 300);/*from  w  w  w  .j a v  a  2s .  c  o m*/

    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jfrm.getRootPane().setDefaultButton(jbtnA);

    jbtnA.setMnemonic(KeyEvent.VK_A);

    jbtnA.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println("Alpha pressed. Beta is enabled.");
            jbtnA.setEnabled(!jbtnA.isEnabled());
        }
    });
    jfrm.add(jbtnA);
    jfrm.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(300, 300);/*from w w w .j a  v a 2 s  .  c om*/
    f.setLocationRelativeTo(null);

    f.setUndecorated(true);
    f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

    JPanel panel = new JPanel();
    panel.setBackground(java.awt.Color.white);
    f.setContentPane(panel);

    MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme());
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
    } catch (Exception e) {
        e.printStackTrace();
    }

    SwingUtilities.updateComponentTreeUI(f);

    f.setVisible(true);
}

From source file:SettingDefaultButton.java

public static void main(String args[]) {
    JFrame frame = new JFrame("DefaultButton");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button4 = new JButton("AAA");
    frame.add(button4, "Center");
    frame.add(new JButton("BBB"), "South");
    JRootPane rootPane = frame.getRootPane();
    rootPane.setDefaultButton(button4);//from   w  w  w  .j  a va  2s .  c o  m
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    ImageIcon iconA = new ImageIcon("IconA.gif");
    ImageIcon iconDiable = new ImageIcon("disable.gif");
    ImageIcon iconOver = new ImageIcon("over.gif");
    ImageIcon iconPressed = new ImageIcon("IconAPressed.gif");

    final JButton jbtnA = new JButton("Alpha", iconA);

    JFrame jfrm = new JFrame();
    jfrm.setLayout(new FlowLayout());
    jfrm.setSize(300, 300);/*from   w  w  w . j a  v  a  2 s  . c  o m*/

    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jbtnA.setRolloverIcon(iconOver);

    jbtnA.setPressedIcon(iconPressed);
    jbtnA.setDisabledIcon(iconDiable);

    jfrm.getRootPane().setDefaultButton(jbtnA);

    jbtnA.setMnemonic(KeyEvent.VK_A);

    jbtnA.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            System.out.println("Alpha pressed. Beta is enabled.");
            jbtnA.setEnabled(!jbtnA.isEnabled());
        }
    });
    jfrm.add(jbtnA);
    jfrm.setVisible(true);
}