Java Code Examples for java.awt.Container#isVisible()

The following examples show how to use java.awt.Container#isVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortingFocusTraversalPolicy.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 2
Source File: SortingFocusTraversalPolicy.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 3
Source File: SortingFocusTraversalPolicy.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 4
Source File: SortingFocusTraversalPolicy.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 5
Source File: SortingFocusTraversalPolicy.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 6
Source File: SortingFocusTraversalPolicy.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 7
Source File: SortingFocusTraversalPolicy.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 8
Source File: SortingFocusTraversalPolicy.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 9
Source File: SortingFocusTraversalPolicy.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 10
Source File: SortingFocusTraversalPolicy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 11
Source File: SortingFocusTraversalPolicy.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 12
Source File: SortingFocusTraversalPolicy.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 13
Source File: SortingFocusTraversalPolicy.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 14
Source File: SortingFocusTraversalPolicy.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 15
Source File: SortingFocusTraversalPolicy.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void enumerateCycle(Container container, List<Component> cycle) {
    if (!(container.isVisible() && container.isDisplayable())) {
        return;
    }

    cycle.add(container);

    Component[] components = container.getComponents();
    for (Component comp : components) {
        if (comp instanceof Container) {
            Container cont = (Container)comp;

            if (!cont.isFocusCycleRoot() &&
                !cont.isFocusTraversalPolicyProvider() &&
                !((cont instanceof JComponent) && ((JComponent)cont).isManagingFocus()))
            {
                enumerateCycle(cont, cycle);
                continue;
            }
        }
        cycle.add(comp);
    }
}
 
Example 16
Source File: SwingUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Positions the specified dialog at a position relative to its parent.
 *
 * @param dialog
 *          the dialog to be positioned.
 * @param horizontalPercent
 *          the relative location.
 * @param verticalPercent
 *          the relative location.
 */
public static void positionDialogRelativeToParent( final Dialog dialog, final double horizontalPercent,
    final double verticalPercent ) {
  final Container parent = dialog.getParent();
  if ( parent == null || ( parent.isVisible() == false ) ) {
    positionFrameOnScreen( dialog, horizontalPercent, verticalPercent );
    return;
  }

  final Dimension d = dialog.getSize();
  final Dimension p = parent.getSize();

  final int baseX = parent.getX();
  final int baseY = parent.getY();

  final int parentPointX = baseX + (int) ( horizontalPercent * p.width );
  final int parentPointY = baseY + (int) ( verticalPercent * p.height );

  final int dialogPointX = Math.max( 0, parentPointX - (int) ( horizontalPercent * d.width ) );
  final int dialogPointY = Math.max( 0, parentPointY - (int) ( verticalPercent * d.height ) );

  // make sure the dialog fits completely on the screen...
  final Rectangle s = parent.getGraphicsConfiguration().getBounds();
  final Rectangle r = new Rectangle( dialogPointX, dialogPointY, d.width, d.height );
  final Rectangle intersectedDialogBounds = r.intersection( s );
  if ( intersectedDialogBounds.width < d.width ) {
    r.x = s.width - d.width;
    r.width = d.width;
  }
  if ( intersectedDialogBounds.height < d.height ) {
    r.y = s.height - d.height;
    r.height = d.height;
  }
  final Rectangle finalIntersection = r.intersection( s );
  dialog.setBounds( finalIntersection );
}
 
Example 17
Source File: ProgressLog.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Update only if visible to avoid opening the window just because
 * the font setting changed.
 */
private void updateOnFontChange() {
	Container top = this.getTopLevelAncestor();
	if (top != null && top.isVisible()) {
		update();
	}
}
 
Example 18
Source File: JOptionPane.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Prompts the user for input in a blocking internal dialog where
 * the initial selection, possible selections, and all other
 * options can be specified. The user will able to choose from
 * <code>selectionValues</code>, where <code>null</code>
 * implies the user can input
 * whatever they wish, usually by means of a <code>JTextField</code>.
 * <code>initialSelectionValue</code> is the initial value to prompt
 * the user with. It is up to the UI to decide how best to represent
 * the <code>selectionValues</code>, but usually a
 * <code>JComboBox</code>, <code>JList</code>, or
 * <code>JTextField</code> will be used.
 *
 * @param parentComponent the parent <code>Component</code> for the dialog
 * @param message  the <code>Object</code> to display
 * @param title    the <code>String</code> to display in the dialog
 *          title bar
 * @param messageType the type of message to be displayed:
 *                  <code>ERROR_MESSAGE</code>, <code>INFORMATION_MESSAGE</code>,
 *                  <code>WARNING_MESSAGE</code>,
 *                  <code>QUESTION_MESSAGE</code>, or <code>PLAIN_MESSAGE</code>
 * @param icon     the <code>Icon</code> image to display
 * @param selectionValues an array of <code>Objects</code> that
 *                  gives the possible selections
 * @param initialSelectionValue the value used to initialize the input
 *                  field
 * @return user's input, or <code>null</code> meaning the user
 *          canceled the input
 */
public static Object showInternalInputDialog(Component parentComponent,
        Object message, String title, int messageType, Icon icon,
        Object[] selectionValues, Object initialSelectionValue) {
    JOptionPane pane = new JOptionPane(message, messageType,
            OK_CANCEL_OPTION, icon, null, null);
    pane.putClientProperty(PopupFactory_FORCE_HEAVYWEIGHT_POPUP,
            Boolean.TRUE);
    Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager().
            getFocusOwner();

    pane.setWantsInput(true);
    pane.setSelectionValues(selectionValues);
    pane.setInitialSelectionValue(initialSelectionValue);

    JInternalFrame dialog =
        pane.createInternalFrame(parentComponent, title);

    pane.selectInitialValue();
    dialog.setVisible(true);

    /* Since all input will be blocked until this dialog is dismissed,
     * make sure its parent containers are visible first (this component
     * is tested below).  This is necessary for JApplets, because
     * because an applet normally isn't made visible until after its
     * start() method returns -- if this method is called from start(),
     * the applet will appear to hang while an invisible modal frame
     * waits for input.
     */
    if (dialog.isVisible() && !dialog.isShowing()) {
        Container parent = dialog.getParent();
        while (parent != null) {
            if (parent.isVisible() == false) {
                parent.setVisible(true);
            }
            parent = parent.getParent();
        }
    }

    AWTAccessor.getContainerAccessor().startLWModal(dialog);

    if (parentComponent instanceof JInternalFrame) {
        try {
            ((JInternalFrame)parentComponent).setSelected(true);
        } catch (java.beans.PropertyVetoException e) {
        }
    }

    if (fo != null && fo.isShowing()) {
        fo.requestFocus();
    }
    Object value = pane.getInputValue();

    if (value == UNINITIALIZED_VALUE) {
        return null;
    }
    return value;
}
 
Example 19
Source File: ControlGridLayout.java    From pumpernickel with MIT License 4 votes vote down vote up
private Map<Component, Rectangle> createBlueprint(Container parent) {
	CellLayout masterLayout;
	if (group.contains(parent)) {
		masterLayout = new CellLayout();
		for (Container container : group) {
			if (container.isVisible()) {
				CellLayout cellLayout = getCellLayout(container);
				masterLayout.add(cellLayout);
			}
		}
	} else {
		masterLayout = getCellLayout(parent);
	}

	int x = 0;
	int y = 0;
	if (parent instanceof JComponent) {
		Border b = ((JComponent) parent).getBorder();
		if (b != null) {
			Insets i = b.getBorderInsets(parent);
			x = i.left;
			y = i.top;
		}
	}

	List<List<Component>> grid = createGrid(parent);

	Map<Component, Rectangle> returnValue = new HashMap<>();
	int y0 = y;
	for (int row = 0; row < grid.size(); row++) {
		int x0 = x;
		for (int column = 0; column < grid.get(row).size(); column++) {
			Component c = grid.get(row).get(column);
			Dimension d = c.getPreferredSize();
			Rectangle r = new Rectangle(x0, y0, d.width, d.height);
			// masterLayout.columnWidths[column],
			// masterLayout.rowHeights[row]);
			returnValue.put(c, r);

			x0 += masterLayout.columnWidths[column];
			x0 += horizontalPadding;
		}
		y0 += masterLayout.rowHeights[row];
		y0 += verticalPadding;
	}

	return returnValue;
}
 
Example 20
Source File: Swing.java    From pdfxtk with Apache License 2.0 4 votes vote down vote up
public static void startModal(javax.swing.JInternalFrame f) {
   synchronized(f) {
     /* Since all input will be blocked until this dialog is dismissed,
      * make sure its parent containers are visible first (this component
      * is tested below).  This is necessary for JApplets, because
      * because an applet normally isn't made visible until after its
      * start() method returns -- if this method is called from start(),
      * the applet will appear to hang while an invisible modal frame
      * waits for input.
      */
     
     if (f.isVisible() && !f.isShowing()) {
Container parent = f.getParent();
while (parent != null) {
  if (parent.isVisible() == false) {
    parent.setVisible(true);
  }
  parent = parent.getParent();
}
     }

     try {
if (SwingUtilities.isEventDispatchThread()) {
  EventQueue theQueue = f.getToolkit().getSystemEventQueue();
  while (f.isVisible()) {
    // This is essentially the body of EventDispatchThread
    AWTEvent event = theQueue.getNextEvent();
    Object src = event.getSource();
    // can't call theQueue.dispatchEvent, so I pasted it's body here
    /*if (event instanceof ActiveEvent) {
      ((ActiveEvent) event).dispatch();
      } else */ if (src instanceof Component) {
	((Component) src).dispatchEvent(event);
      } else if (src instanceof MenuComponent) {
	((MenuComponent) src).dispatchEvent(event);
      } else {
	System.err.println("unable to dispatch event: " + event);
      }
  }
} else
  while (f.isVisible())
    f.wait();
     } catch(InterruptedException e){}
   }
 }