Java JComponent Properties showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible)

Here you can find the source of showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible)

Description

show As Only Visible Child

License

LGPL

Declaration

public static void showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.JComponent;

public class Main {
    public static void showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible) {
        for (Component child : container.getComponents()) {
            boolean visible = child.equals(childToBeMadeVisible);
            child.setVisible(visible);/*from   w  w  w  .ja va 2  s. c om*/
            if (visible) {
                container.getLayout().addLayoutComponent(BorderLayout.CENTER, child);
            } else {
                container.getLayout().removeLayoutComponent(child);
            }
            child.repaint();
        }
        container.revalidate();
        container.repaint();
    }
}

Related

  1. setComponentEnabled(JComponent component, Boolean isEnabled)
  2. setDirty(JComponent comp, boolean isDirty)
  3. setGlassPane(JComponent comp, Component glass, boolean visible)
  4. setLegendVisible(JComponent chartUI, boolean visible)
  5. setLightweightDispatcher(JComponent component)
  6. showSplash(JComponent content, int milliseconds)
  7. showSplash(JComponent content, int milliseconds, boolean start_timer)