Here you can find the source of resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp)
public static void resetDisplayComponent(JComponent mainComp, JComponent nonDispComp, JComponent newDispComp)
//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(); } }