Java JComponent Properties resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp)

Here you can find the source of resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp)

Description

reset Display Component

License

Apache License

Declaration

public static void resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp) 

Method Source Code

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

import java.awt.BorderLayout;

import javax.swing.JComponent;

public class Main {
    public static void resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp) {
        JComponent[] nonDispComps = { nonDispComp };
        resetDisplayComponent(mainComp, nonDispComps, newDispComp);
    }/* w  ww .jav a  2 s  .com*/

    public static void resetDisplayComponent(JComponent mainComp, JComponent[] nonDispComps,
            JComponent newDispComp) {
        int zorder = -1;
        if (mainComp == null || nonDispComps == null || newDispComp == null)
            return;
        // RGPTLogger.logToFile("Resetting the Display Component");
        for (int i = 0; i < nonDispComps.length; i++) {
            zorder = mainComp.getComponentZOrder(nonDispComps[i]);
            if (zorder != -1)
                mainComp.remove(nonDispComps[i]);
        }
        zorder = mainComp.getComponentZOrder(newDispComp);
        if (zorder == -1)
            mainComp.add(newDispComp, BorderLayout.CENTER);
        mainComp.revalidate();
    }
}

Related

  1. isVisible(JComponent c, Rectangle r)
  2. isVisible(JComponent comp)
  3. isVisibleOnScreen(final JComponent component)
  4. registerComponent(JComponent c)
  5. registerDataFlavors(JComponent component, DataFlavor... dataFlavors)
  6. setComponentEnabled(JComponent component, Boolean isEnabled)
  7. setDirty(JComponent comp, boolean isDirty)
  8. setGlassPane(JComponent comp, Component glass, boolean visible)
  9. setLegendVisible(JComponent chartUI, boolean visible)