Java Code Examples for javax.swing.JComponent#isShowing()
The following examples show how to use
javax.swing.JComponent#isShowing() .
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: SwingSet3.java From littleluck with Apache License 2.0 | 6 votes |
public void hierarchyChanged(HierarchyEvent event) { if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) { JComponent component = (JComponent)event.getComponent(); final Demo demo = (Demo)component.getClientProperty("swingset3.demo"); if (!component.isShowing()) { demo.stop(); } else { demoContainer.revalidate(); EventQueue.invokeLater(new Runnable() { public void run() { demo.start(); } }); } } }
Example 2
Source File: ExcelSheetSelectionPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a bubble for the component and kills other bubbles. * * @param component * the component for which to show the bubble * @param style * the bubble style * @param i18n * the i18n key * @param arguments * arguments for the i18n */ private void createBubbleWindow(JComponent component, BubbleStyle style, String i18n, Object... arguments) { // BubbleWindow requires a visible owner if (!component.isShowing()) { return; } killCurrentBubbleWindow(null); bubbleOwner = component; JButton okayButton = new JButton(I18N.getGUILabel("io.dataimport.step.excel.sheet_selection.got_it")); final ComponentBubbleWindow errorWindow = new ComponentBubbleWindow(component, style, SwingUtilities.getWindowAncestor(ExcelSheetSelectionPanel.this), AlignedSide.TOP, i18n, null, null, false, true, new JButton[] { okayButton }, arguments); okayButton.addActionListener(e -> errorWindow.killBubble(false)); // show and remember error window errorWindow.setVisible(true); currentBubbleWindow = errorWindow; }
Example 3
Source File: DefaultSwingBundleDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void valueChanged(long bid) { boolean bHasVisibleComponent = false; synchronized (components) { for (final JComponent comp : components) { if (comp.isShowing()) { bHasVisibleComponent = true; break; } } } lastBID = bid; if (bHasVisibleComponent) { valueChangedLazy(bid); } }
Example 4
Source File: DefaultSwingBundleDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void valueChanged(long bid) { boolean bHasVisibleComponent = false; synchronized (components) { for (final JComponent comp : components) { if (comp.isShowing()) { bHasVisibleComponent = true; break; } } } lastBID = bid; if (bHasVisibleComponent) { valueChangedLazy(bid); } }
Example 5
Source File: DefaultSwingBundleDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void valueChanged(long bid) { boolean bHasVisible = false; for (final JComponent comp : components) { if (comp.isShowing()) { bHasVisible = true; break; } } lastBID = bid; if (bHasVisible) { valueChangedLazy(bid); } }
Example 6
Source File: SwingSet3.java From beautyeye with Apache License 2.0 | 6 votes |
public void hierarchyChanged(HierarchyEvent event) { if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) { JComponent component = (JComponent)event.getComponent(); final Demo demo = (Demo)component.getClientProperty("swingset3.demo"); if (!component.isShowing()) { demo.stop(); } else { demoContainer.revalidate(); EventQueue.invokeLater(new Runnable() { public void run() { demo.start(); } }); } } }
Example 7
Source File: RunManagerTest.java From ghidra with Apache License 2.0 | 5 votes |
private void waitForComponentToBeHidden(JComponent component) { int numWaits = 0; int sleepyTime = 100; int maxWaits = 20; while (component.isShowing() && maxWaits > numWaits++) { sleep(sleepyTime); } if (numWaits >= maxWaits) { Assert.fail("Component not hidden!"); } }
Example 8
Source File: ToolbarVisibleTest.java From netbeans with Apache License 2.0 | 5 votes |
private void assertVisible(String msg, JComponent tc) throws InterruptedException { int cnt = 0; while (!tc.isShowing()) { Thread.sleep(100); if (cnt++ > 10) { break; } } assertTrue(msg + ". Showing", tc.isShowing()); }
Example 9
Source File: BasicPopoverVisibility.java From pumpernickel with MIT License | 5 votes |
/** * Calculate whether a popover should be visible or not. * <p> * The default implementation takes into account the keybord focus, mouse * position, and expanded state. * * @param popover * the JPopover to evaluate * @return true if the popover should be visible. */ @Override public boolean isVisible(JPopover<T> popover) { JComponent owner = popover.getOwner(); JComponent contents = popover.getContents(); boolean newVisible; if (owner.isShowing() && owner.isEnabled()) { newVisible = isFocusOwnerOrAncestor(owner) || isRollover(owner); if (!newVisible && popover.isRolloverContents()) { newVisible = isFocusOwnerOrAncestor(contents) || (isRollover(contents)); } } else { newVisible = false; } if (isExpanded(owner)) { newVisible = false; } if (isInsideActiveWindow(owner) == false && isInsideActiveWindow(contents) == false) newVisible = false; return newVisible; }
Example 10
Source File: BasicPopoverVisibility.java From pumpernickel with MIT License | 5 votes |
/** * Return true if the mouse is currently over the argument. */ protected boolean isRollover(JComponent jc) { if (!jc.isShowing()) return false; Point p = jc.getLocationOnScreen(); int w = jc.getWidth(); int h = jc.getHeight(); Point mouse = MouseInfo.getPointerInfo().getLocation(); return mouse.x >= p.x && mouse.y >= p.y && mouse.x < p.x + w && mouse.y < p.y + h; }
Example 11
Source File: CheckThreadViolationRepaintManager.java From wpcleaner with Apache License 2.0 | 5 votes |
private void checkThreadViolations(JComponent c) { if (!SwingUtilities.isEventDispatchThread() && (completeCheck || c.isShowing())) { boolean repaint = false; boolean fromSwing = false; boolean imageUpdate = false; StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (StackTraceElement st : stackTrace) { if (repaint && st.getClassName().startsWith("javax.swing.") && // for details see // https://swinghelper.dev.java.net/issues/show_bug.cgi?id=1 !st.getClassName().startsWith("javax.swing.SwingWorker")) { fromSwing = true; } if (repaint && "imageUpdate".equals(st.getMethodName())) { imageUpdate = true; } if ("repaint".equals(st.getMethodName())) { repaint = true; fromSwing = false; } } if (imageUpdate) { //assuming it is java.awt.image.ImageObserver.imageUpdate(...) //image was asynchronously updated, that's ok return; } if (repaint && !fromSwing) { //no problems here, since repaint() is thread safe return; } //ignore the last processed component if (lastComponent != null && c == lastComponent.get()) { return; } lastComponent = new WeakReference<JComponent>(c); violationFound(c, stackTrace); } }
Example 12
Source File: FlutterProjectStepFixture.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static boolean isShown(JComponent field) { return field.isVisible() && field.isShowing(); }
Example 13
Source File: SpotlightPanel.java From pumpernickel with MIT License | 4 votes |
protected void recalculateHighlight(boolean forceImmediateUpdate) { Rectangle highlightSum = null; for (JComponent h : highlightedComponents) { if (h.isShowing() && h.getParent() != null) { Rectangle r = h.getBounds(); r = SwingUtilities.convertRectangle(h.getParent(), r, this); if (highlightSum == null) { highlightSum = r; } else { highlightSum.add(r); } } } if (highlightSum == null) { putClientProperty(TARGET_ALPHA, 0f); } else { putClientProperty(TARGET_ALPHA, 1f); putClientProperty(TARGET_X, (float) highlightSum.getX()); putClientProperty(TARGET_Y, (float) highlightSum.getY()); putClientProperty(TARGET_WIDTH, (float) highlightSum.getWidth()); putClientProperty(TARGET_HEIGHT, (float) highlightSum.getHeight()); } if (getClientProperty(REAL_X) == null) { putClientProperty(REAL_ALPHA, 0); putClientProperty(REAL_X, getClientProperty(TARGET_X)); putClientProperty(REAL_Y, getClientProperty(TARGET_Y)); putClientProperty(REAL_WIDTH, getClientProperty(TARGET_WIDTH)); putClientProperty(REAL_HEIGHT, getClientProperty(TARGET_HEIGHT)); } if (forceImmediateUpdate) { putClientProperty(REAL_ALPHA, getClientProperty(TARGET_ALPHA)); putClientProperty(REAL_X, getClientProperty(TARGET_X)); putClientProperty(REAL_Y, getClientProperty(TARGET_Y)); putClientProperty(REAL_WIDTH, getClientProperty(TARGET_WIDTH)); putClientProperty(REAL_HEIGHT, getClientProperty(TARGET_HEIGHT)); } }