List of usage examples for javax.swing JComponent getTopLevelAncestor
@BeanProperty(bound = false) @SuppressWarnings("deprecation") public Container getTopLevelAncestor()
Window
or Applet
), or null
if this component has not been added to any container. From source file:Main.java
public static boolean isFrameActive(JComponent c) { return c != null && (!(c.getTopLevelAncestor() instanceof Window) || isWindowActive((Window) c.getTopLevelAncestor())); }
From source file:Main.java
public static boolean isFrameActive(JComponent c) { if (c == null) { return false; }//from ww w .j av a2s . co m if (c.getTopLevelAncestor() instanceof Window) { return isWindowActive((Window) c.getTopLevelAncestor()); } return true; }
From source file:Main.java
public static void swapComponentsAndResizeUI(JComponent ui, JComponent current, JComponent next) { ui.remove(current);/*from www . j a va 2s . c o m*/ ui.add(next); current = next; Component c = ui.getTopLevelAncestor(); if (c instanceof Window) { Window w = (Window) c; w.pack(); } }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Returns a <code>MouseListener</code> that changes the cursor and * notifies <code>actionListener</code> on click. *//*ww w. j a v a 2s . c o m*/ public static MouseListener getURLInputListener(final ActionListener actionListener) { return new MouseAdapter() { public void mouseEntered(MouseEvent e) { JComponent comp = (JComponent) e.getComponent(); comp.getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { JComponent comp = (JComponent) e.getComponent(); comp.getTopLevelAncestor().setCursor(Cursor.getDefaultCursor()); } public void mouseClicked(MouseEvent e) { actionListener.actionPerformed(new ActionEvent(e.getComponent(), 0, null)); } }; }