/** * Tries to determine the dialog this panel is part of. * * @return the parent dialog if one exists or null if not */ public Dialog getParentDialog() { return GUIHelper.getParentDialog(this); }
/** * Tries to determine the component this panel is part of in this order: * 1. dialog, 2. child, 3. frame. * * @param comp the component to get the parent component for, must * be a container actually * @return the parent component if one exists or null if not * @see #getParentDialog(Container) * @see #getParentFrame(Container) */ public static Component getParentComponent(Component comp) { Component result; Container cont; if (comp == null) return null; if (comp instanceof Container) cont = (Container) comp; else return null; result = getParentDialog(cont); if (result == null) result = getParentFrame(cont); return result; }
/** * Performs the actual choosing of an object. * * @return the chosen object or null if none chosen */ protected Font doChoose() { if (m_FontChooser == null) { if (GUIHelper.getParentDialog(this) != null) m_FontChooser = new FontChooser(GUIHelper.getParentDialog(this)); else m_FontChooser = new FontChooser(GUIHelper.getParentFrame(this)); } m_FontChooser.setCurrent(getCurrent()); m_FontChooser.setVisible(true); return m_FontChooser.getCurrent(); }
WindowEvent event; if (getParentDialog(cont) != null) { dialog = getParentDialog(cont); dialog.setVisible(false);