Example usage for javax.swing JFrame setGlassPane

List of usage examples for javax.swing JFrame setGlassPane

Introduction

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

Prototype

@BeanProperty(bound = false, hidden = true, description = "A transparent pane used for menu rendering.")
public void setGlassPane(Component glassPane) 

Source Link

Document

Sets the glassPane property.

Usage

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();

    final JButton activate = new JButton("Show");
    frame.add(activate);//from  w  w  w . ja v a 2  s  . c  o  m

    frame.pack();
    frame.setVisible(true);

    final Main glass = new Main(frame);
    frame.setGlassPane(glass);

    activate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            glass.setVisible(true);
        }
    });
}

From source file:lcmc.LCMC.java

/** The main function for starting the application. */
public static void main(final String[] args) {
    Tools.init();/*  w  w w.  j ava 2 s.c o m*/
    final JFrame mainFrame = new JFrame(Tools.getString("DrbdMC.Title") + " " + Tools.getRelease());
    final List<Image> il = new ArrayList<Image>();
    for (final String iconS : new String[] { "LCMC.AppIcon32", "LCMC.AppIcon48", "LCMC.AppIcon64",
            "LCMC.AppIcon128", "LCMC.AppIcon256" }) {
        il.add(Tools.createImageIcon(Tools.getDefault(iconS)).getImage());
    }
    mainFrame.setIconImages(il);
    final String autoArgs = initApp(args);
    mainFrame.setGlassPane(getMainGlassPane());
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.addWindowListener(new ExitListener());
    mainFrame.setJMenuBar(getMenuBar());
    mainFrame.setContentPane(getMainPanel());
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI((Container) mainFrame);
        }
    });
    if (autoArgs != null) {
        Tools.parseAutoArgs(autoArgs);
    }
    //final Thread t = new Thread(new Runnable() {
    //    public void run() {
    //        drbd.utilities.RoboTest.startMover(600000, true);
    //    }
    //});
    //t.start();
}

From source file:components.GlassPaneDemo.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 . co m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("GlassPaneDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Start creating and adding components.
    JCheckBox changeButton = new JCheckBox("Glass pane \"visible\"");
    changeButton.setSelected(false);

    //Set up the content pane, where the "main GUI" lives.
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(changeButton);
    contentPane.add(new JButton("Button 1"));
    contentPane.add(new JButton("Button 2"));

    //Set up the menu bar, which appears above the content pane.
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Menu");
    menu.add(new JMenuItem("Do nothing"));
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);

    //Set up the glass pane, which appears over both menu bar
    //and content pane and is an item listener on the change
    //button.
    myGlassPane = new MyGlassPane(changeButton, menuBar, frame.getContentPane());
    changeButton.addItemListener(myGlassPane);
    frame.setGlassPane(myGlassPane);

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

From source file:GlassPaneDemo.java

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

    // Start creating and adding components.
    JCheckBox changeButton = new JCheckBox("Glass pane \"visible\"");
    changeButton.setSelected(false);

    // Set up the content pane, where the "main GUI" lives.
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(changeButton);
    contentPane.add(new JButton("Button 1"));
    contentPane.add(new JButton("Button 2"));

    // Set up the menu bar, which appears above the content pane.
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Menu");
    menu.add(new JMenuItem("Do nothing"));
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);

    // Set up the glass pane, which appears over both menu bar
    // and content pane and is an item listener on the change
    // button.
    myGlassPane = new MyGlassPane(changeButton, menuBar, frame.getContentPane());
    changeButton.addItemListener(myGlassPane);
    frame.setGlassPane(myGlassPane);

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

From source file:net.sourceforge.metware.binche.execs.BiNCheExec.java

private void runGui() {

    final JFrame window = new JFrame("binche Settings");
    final SettingsPanel settingsPanel = new SettingsPanel();
    window.getContentPane().add(settingsPanel);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setGlassPane(settingsPanel.getProgressPanel());
    window.pack();/*from   w  ww  . ja  v  a 2  s  .co  m*/

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    window.setLocation(screenSize.width / 2 - (window.getWidth() / 2),
            screenSize.height / 2 - (window.getHeight() / 2));
    window.setVisible(true);
    window.setResizable(true);
}

From source file:org.martus.client.swingui.FxInSwingMainWindow.java

protected void hideActiveWindowContent() {
    JFrame frame = getCurrentActiveFrame().getSwingFrame();
    if (frame != null) {
        frame.setGlassPane(new WindowObscurer());
        frame.getGlassPane().setVisible(true);
    }// w ww.  j a v a2s  .c  o m

    JDialog dialog = getCurrentActiveDialog();
    if (dialog != null) {
        dialog.setGlassPane(new WindowObscurer());
        dialog.getGlassPane().setVisible(true);
    }
}