Example usage for java.awt Component setVisible

List of usage examples for java.awt Component setVisible

Introduction

In this page you can find the example usage for java.awt Component setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this component depending on the value of parameter b .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Create an action
    Action action = new AbstractAction("Action Label") {
        // This method is called when the action is triggered
        public void actionPerformed(ActionEvent evt) {
            Component c = (Component) evt.getSource();

            // Get the frame
            Component frame = SwingUtilities.getRoot(c);

            // Hide the frame
            frame.setVisible(false);
        }//  ww  w.  ja  va 2s . co  m
    };

}

From source file:pcgen.system.Main.java

/**
 * @param args the command line arguments
 *//*from   w ww .ja  va  2s. c o  m*/
public static void main(String[] args) {
    Logging.log(Level.INFO, "Starting PCGen v" + PCGenPropBundle.getVersionNumber() //$NON-NLS-1$
            + PCGenPropBundle.getAutobuildString());

    Thread.setDefaultUncaughtExceptionHandler(new PCGenUncaughtExceptionHandler());
    logSystemProps();
    configFactory = new PropertyContextFactory(getConfigPath());
    configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance());

    parseCommands(args);

    if (startNameGen) {
        Component dialog = new RandomNameDialog(null, null);
        dialog.setVisible(true);
        System.exit(0);
    }

    if (exportSheet == null) {
        startupWithGUI();
    } else {
        startupWithoutGUI();
        shutdown();
    }
}

From source file:Main.java

public static void hide(Component... components) {
    for (Component component : components) {
        component.setVisible(false);
    }/* w  w  w  .ja  va2s.c  o m*/
}

From source file:Main.java

public static void show(Component... components) {
    for (Component component : components) {
        component.setVisible(true);
    }/*  ww  w.  ja v  a2 s  .c  o  m*/
}

From source file:Main.java

/** Set the visible property of the given components.  Intended to reduce clutter in GUI code. */
public static void setVisible(boolean b, Component... components) {
    for (Component c : components) {
        c.setVisible(b);
    }/* w w  w.j ava 2  s.co m*/
}

From source file:Main.java

public static void setVisible(Component container, boolean visible) {
    if (container instanceof Container) {
        for (Component component : ((Container) container).getComponents()) {
            component.setVisible(visible);
            if (component instanceof Container) {
                setVisible(component, visible);
            }/*from   w  w  w  .  jav  a  2  s .  c o m*/
        }
    }
    container.setVisible(visible);
}

From source file:Main.java

private static void doSetVisibleInEDT(final Component component, final boolean isVisible) {
    component.setVisible(isVisible);
}

From source file:Main.java

public static void hideComponents(Container container) {
    for (Component component : container.getComponents()) {
        if (component instanceof Container) {
            component.setVisible(false);
        }//from   www .  j  av  a  2  s .c o m
    }
}

From source file:Main.java

public static void showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible) {
    for (Component child : container.getComponents()) {
        boolean visible = child.equals(childToBeMadeVisible);
        child.setVisible(visible);
        if (visible) {
            container.getLayout().addLayoutComponent(BorderLayout.CENTER, child);
        } else {/*from w w  w.jav  a2 s  . co m*/
            container.getLayout().removeLayoutComponent(child);
        }
        child.repaint();
    }
    container.revalidate();
    container.repaint();
}

From source file:Main.java

public static void setVisible(final Component component, final boolean isVisible) {
    if (component != null) {
        runInEDT(() -> component.setVisible(isVisible));
    }//from  ww w  . j  ava 2s. c  o m
}