private void disposeAndUpdate(boolean update) { if (myView != null) { boolean visible = myView.isVisible(); myView.setVisible(false); Container container = myContent.getParent(); if (container != null) { container.remove(myContent); } if (myView instanceof Window) { myViewBounds = myView.getBounds(); Window window = (Window) myView; if (!push(UIUtil.getWindow(myOwner), window)) { window.dispose(); } } else { Container parent = myView.getParent(); if (parent == null) { myViewBounds = new Rectangle(myContent.getPreferredSize()); } else { myViewBounds = new Rectangle(myView.getBounds()); parent.remove(myView); Point point = new Point(myViewBounds.x, myViewBounds.y); SwingUtilities.convertPointToScreen(point, parent); myViewBounds.x = point.x; myViewBounds.y = point.y; } } myView = null; if (update && visible) { setVisible(true); } } }
/** * Creates a new AWT <tt>Container</tt> which can display a single <tt>Component</tt> at a time * (supposedly, one which represents video) and, in the absence of such a <tt>Component</tt>, * displays a predefined default <tt>Component</tt> (in accord with the previous supposition, one * which is the default when there is no video). The returned <tt>Container</tt> will track the * <tt>Components</tt>s added to and removed from it in order to make sure that * <tt>noVideoContainer</tt> is displayed as described. * * @param noVideoComponent the predefined default <tt>Component</tt> to be displayed in the * returned <tt>Container</tt> when there is no other <tt>Component</tt> in it * @return a new <tt>Container</tt> which can display a single <tt>Component</tt> at a time and, * in the absence of such a <tt>Component</tt>, displays <tt>noVideoComponent</tt> */ private VideoContainer createVideoContainer(Component noVideoComponent) { Container oldParent = noVideoComponent.getParent(); if (oldParent != null) oldParent.remove(noVideoComponent); return new VideoContainer(noVideoComponent, false); }
public void run() { try { clientProcess.waitFor(); } catch (InterruptedException ie) { } parent.remove(client); }
private void cancelButtonActionPerformed(ActionEvent e) { cont.remove(this); cont.setCurrent(previous); cont.add(cont.getCurrent()); cont.revalidate(); cont.repaint(); }
/** * Replace the current contents of the frame's content pane. * * @param panel JPanel of the new contents of the content pane. */ public void replace(JPanel panel) { // Removes everything from the content pane. for (int i = 0; i < pane.getComponentCount(); i++) { pane.remove(i); } pane.add(panel); }
public static void setRelativeBounds( @NotNull Component parent, @NotNull Rectangle bounds, @NotNull Component child, @NotNull Container validationParent) { validationParent.add(parent); parent.setBounds(bounds); parent.validate(); child.setLocation(SwingUtilities.convertPoint(child, 0, 0, parent)); validationParent.remove(parent); }
public void propertyChange(PropertyChangeEvent evt) { if (DisplayOptions.isUpdateUIEvent(evt)) { SwingUtilities.updateComponentTreeUI(this); gradientPanel.remove(drawable); JPanel newpanel = createGradientPanel(); contentPane.remove(gradientPanel); gradientPanel = newpanel; gradientPanel.add(drawable, BorderLayout.CENTER); contentPane.add(gradientPanel, BorderLayout.CENTER); } }
@Override public void dispose() { myLastComponent = null; myFirstComponent = null; myInnerComponent = null; removeAll(); Container container = getParent(); if (container != null) { container.remove(this); } }
private void saveButtonActionPerformed(ActionEvent e) { String animal = animalField.getText(); String color = colorField.getText(); String name = nameField.getText(); try { facade.addNewTrial(animal, color, name); } catch (Exception ex) { showError(); ex.printStackTrace(); return; } cont.remove(this); cont.setCurrent(previous); cont.add(cont.getCurrent()); cont.revalidate(); cont.repaint(); }
public void showPinObj(PushpinIF pobj, boolean on) { Component comp = (Component) pobj; if (comp == null) return; Container p = comp.getParent(); if (!on) { pobj.setPopup(false, true); if (p != null && p != tabbedPane) { p.remove(comp); p.validate(); p.repaint(); } if (popupComp == comp) popupComp = null; return; } if (popupComp != null) { if (popupComp != comp) { ((PushpinIF) popupComp).setPopup(false, true); p = popupComp.getParent(); if (p != null && p != tabbedPane) { p.remove(popupComp); } } popupComp = null; } /* if (!isShowing()) { return; } */ if (comp.isShowing()) { return; } Container p2 = null; p = pinPanel.getParent(); while (p != null) { if (p instanceof JLayeredPane) p2 = p; p = p.getParent(); } if (p2 == null) return; if (!isShowing()) { VnmrjIF vif = Util.getVjIF(); vif.raiseToolPanel(on); setVisible(true); } popupComp = comp; p = p2; pobj.setPopup(true, true); /* Point pt0 = p.getLocationOnScreen(); Point pt1 = getLocationOnScreen(); */ Point pt1 = getLocation(); Dimension dim = getSize(); int y0 = (int) ((float) dim.height * pobj.getRefY()); int h = (int) ((float) dim.height * pobj.getRefH()); int x = pt1.x + 2; int y = pt1.y + y0; p.add(comp, JLayeredPane.MODAL_LAYER); comp.setBounds(x, y, dim.width, dim.height - y0); ((JComponent) p).validate(); /* p.repaint(); */ }
public void setParent(JComponent c) { Container oldParent = this.getParent(); oldParent.remove(this); c.add(this); // System.out.println("Switched parents from " + oldParent + " to " + c); }
/** * Removes all items from the given container. * * @param container container. */ public void removeAllItemsFrom(Container container) { for (ResultItemPanel item : items) container.remove(item); }