List of usage examples for java.awt Container add
public void add(Component comp, Object constraints, int index)
From source file:Main.java
public static void replaceComponent(Container cont, Component comp1, Component comp2, String constraints) { int index = -1; int i = 0;/*from www. j a v a 2 s. com*/ for (Component comp : cont.getComponents()) { if (comp.equals(comp1)) { index = i; break; } ++i; } // cont.setIgnoreRepaint(true); cont.remove(comp1); cont.add(comp2, constraints, index); cont.validate(); // cont.setIgnoreRepaint(false); cont.repaint(); }