Java Code Examples for javax.swing.PopupFactory#getPopup()
The following examples show how to use
javax.swing.PopupFactory#getPopup() .
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: LayoutPopupManager.java From Logisim with GNU General Public License v3.0 | 6 votes |
private void showPopup(Set<AppearancePort> portObjects) { dragStart = null; CircuitState circuitState = canvas.getCircuitState(); if (circuitState == null) return; ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size()); for (AppearancePort portObject : portObjects) { ports.add(portObject.getPin()); } hideCurrentPopup(); LayoutThumbnail layout = new LayoutThumbnail(); layout.setCircuit(circuitState, ports); JViewport owner = canvasPane.getViewport(); Point ownerLoc = owner.getLocationOnScreen(); Dimension ownerDim = owner.getSize(); Dimension layoutDim = layout.getPreferredSize(); int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5); int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5); PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y); popup.show(); curPopup = popup; curPopupTime = System.currentTimeMillis(); }
Example 2
Source File: ProfilerTableHover.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void showPopup(Painter p, Rectangle rect) { mouse.deinstall(); Point l = table.getLocationOnScreen(); rect.translate(l.x, l.y); popupRect = rect; popupLocation = new Point(l.x + p.getX(), l.y + p.getY()); PopupFactory popupFactory = PopupFactory.getSharedInstance(); popup = popupFactory.getPopup(table, p, popupLocation.x, popupLocation.y); popup.show(); paranoid = new Paranoid(p); paranoid.install(); awt = new AWT(); awt.install(); }
Example 3
Source File: Popup401.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void run() { JPanel panel = new JPanel(); int count = 0; long diffTime, initialDiffTime = 0; while (count < ITERATION_NUMBER) { robot.delay(ROBOT_DELAY); PopupFactory factory = PopupFactory.getSharedInstance(); Popup popup = factory.getPopup(panel, textArea, editorPane.getLocation().x + 20, editorPane.getLocation().y + 20); long startTime = System.currentTimeMillis(); popup.show(); long endTime = System.currentTimeMillis(); diffTime = endTime - startTime; if (count > 1) { if (diffTime * HANG_TIME_FACTOR < (endTime - startTime)) { throw new RuntimeException("The test is near to be hang: iteration count = " + count + " initial time = " + initialDiffTime + " current time = " + diffTime); } } else { initialDiffTime = diffTime; } count++; robot.delay(ROBOT_DELAY); popup.hide(); } }
Example 4
Source File: LuceneDataStoreSearchGUI.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
private void addStatistics(String kind, int count, int numRow, final MouseEvent e) { JLabel label = (JLabel)e.getComponent(); if(!label.getToolTipText().contains(kind)) { // add the statistics to the tooltip String toolTip = label.getToolTipText(); toolTip = toolTip.replaceAll("</?html>", ""); toolTip = kind + " = " + count + "<br>" + toolTip; toolTip = "<html>" + toolTip + "</html>"; label.setToolTipText(toolTip); } if(bottomSplitPane.getDividerLocation() / bottomSplitPane.getSize().getWidth() < 0.90) { // select the row in the statistics table statisticsTabbedPane.setSelectedIndex(1); oneRowStatisticsTable.setRowSelectionInterval(numRow, numRow); oneRowStatisticsTable.scrollRectToVisible(oneRowStatisticsTable .getCellRect(numRow, 0, true)); } else { // display a tooltip JToolTip tip = label.createToolTip(); tip.setTipText(kind + " = " + count); PopupFactory popupFactory = PopupFactory.getSharedInstance(); final Popup tipWindow = popupFactory.getPopup(label, tip, e.getX() + e.getComponent().getLocationOnScreen().x, e.getY() + e.getComponent().getLocationOnScreen().y); tipWindow.show(); Date timeToRun = new Date(System.currentTimeMillis() + 2000); Timer timer = new Timer("Annic statistics hide tooltip timer", true); timer.schedule(new TimerTask() { @Override public void run() { // hide the tooltip after 2 seconds tipWindow.hide(); } }, timeToRun); } }
Example 5
Source File: LuceneDataStoreSearchGUI.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
private void addStatistics(String kind, int count, int numRow, final MouseEvent e) { JLabel label = (JLabel)e.getComponent(); if(!label.getToolTipText().contains(kind)) { // add the statistics to the tooltip String toolTip = label.getToolTipText(); toolTip = toolTip.replaceAll("</?html>", ""); toolTip = kind + " = " + count + "<br>" + toolTip; toolTip = "<html>" + toolTip + "</html>"; label.setToolTipText(toolTip); } if(bottomSplitPane.getDividerLocation() / bottomSplitPane.getSize().getWidth() < 0.90) { // select the row in the statistics table statisticsTabbedPane.setSelectedIndex(1); oneRowStatisticsTable.setRowSelectionInterval(numRow, numRow); oneRowStatisticsTable.scrollRectToVisible(oneRowStatisticsTable .getCellRect(numRow, 0, true)); } else { // display a tooltip JToolTip tip = label.createToolTip(); tip.setTipText(kind + " = " + count); PopupFactory popupFactory = PopupFactory.getSharedInstance(); final Popup tipWindow = popupFactory.getPopup(label, tip, e.getX() + e.getComponent().getLocationOnScreen().x, e.getY() + e.getComponent().getLocationOnScreen().y); tipWindow.show(); Date timeToRun = new Date(System.currentTimeMillis() + 2000); Timer timer = new Timer("Annic statistics hide tooltip timer", true); timer.schedule(new TimerTask() { @Override public void run() { // hide the tooltip after 2 seconds tipWindow.hide(); } }, timeToRun); } }
Example 6
Source File: CompletionLayoutPopup.java From netbeans with Apache License 2.0 | 5 votes |
/** * Create and display the popup at the given bounds. * * @param popupBounds location and size of the popup. * @param displayAboveCaret whether the popup is displayed above the anchor * bounds or below them (it does not be right above them). */ private void show(Rectangle popupBounds, boolean displayAboveCaret) { // Hide the original popup if exists if (popup != null) { popup.hide(); popup = null; } // Explicitly set the preferred size Dimension origPrefSize = getPreferredSize(); Dimension newPrefSize = popupBounds.getSize(); JComponent contComp = getContentComponent(); if (contComp == null){ return; } contComp.setPreferredSize(newPrefSize); showRetainedPreferredSize = newPrefSize.equals(origPrefSize); PopupFactory factory = PopupFactory.getSharedInstance(); // Lightweight completion popups don't work well on the Mac - trying // to click on its scrollbars etc. will cause the window to be hidden, // so force a heavyweight parent by passing in owner==null. (#96717) JTextComponent owner = getEditorComponent(); if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N owner = null; } // #76648: Autocomplete box is too close to text if(displayAboveCaret && Utilities.isMac()) { popupBounds.y -= 10; } popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y); popup.show(); this.popupBounds = popupBounds; this.displayAboveCaret = displayAboveCaret; }
Example 7
Source File: VisualDesignerPopupMenuUI.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = layer.hackedPopupFactory; if(popupFactory == null) { return super.getPopup(popup, x, y); } return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 8
Source File: CompletionLayoutPopup.java From netbeans with Apache License 2.0 | 5 votes |
/** * Create and display the popup at the given bounds. * * @param popupBounds location and size of the popup. * @param displayAboveCaret whether the popup is displayed above the anchor * bounds or below them (it does not be right above them). */ private void show(Rectangle popupBounds, boolean displayAboveCaret) { // Hide the original popup if exists if (popup != null) { popup.hide(); popup = null; } // Explicitly set the preferred size Dimension origPrefSize = getPreferredSize(); Dimension newPrefSize = popupBounds.getSize(); JComponent contComp = getContentComponent(); if (contComp == null){ return; } contComp.setPreferredSize(newPrefSize); showRetainedPreferredSize = newPrefSize.equals(origPrefSize); PopupFactory factory = PopupFactory.getSharedInstance(); // Lightweight completion popups don't work well on the Mac - trying // to click on its scrollbars etc. will cause the window to be hidden, // so force a heavyweight parent by passing in owner==null. (#96717) JTextComponent owner = layout.getEditorComponent(); if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { owner = null; } // #76648: Autocomplete box is too close to text if(displayAboveCaret && Utilities.isMac()) { popupBounds.y -= 10; } popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y); popup.show(); this.popupBounds = popupBounds; this.displayAboveCaret = displayAboveCaret; }
Example 9
Source File: AbstractPatchedTransferHandler.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
private void showPopupAtMousePosition() { // StaticDebug.debug("DND POPUP: Show popup at Mouse position"); // get mouse location Point screenLocation = MouseInfo.getPointerInfo().getLocation(); screenLocation.x += 26; screenLocation.y += 10; // if tooltip is shown if (tipWindow != null) { // StaticDebug.debug("DND POPUP: Popup is already shown"); // check if mouse has moved if (mouseX != screenLocation.x || mouseY != screenLocation.y) { // StaticDebug.debug("DND POPUP: old position x = "+mouseX); // StaticDebug.debug("DND POPUP: old position y = "+mouseY); // StaticDebug.debug("DND POPUP: new position x = "+screenLocation.x); // StaticDebug.debug("DND POPUP: new position y = "+screenLocation.y); // StaticDebug.debug("DND POPUP: Mouse position has changed.. hide popup first"); // hide tooltip hideDropDeniedTooltip(); } else { // StaticDebug.debug("DND POPUP: Restart hide timer to prevent popup from being hidden."); // otherwise restart hide timer hideTimer.restart(); return; } } Point componentLocation = (Point) screenLocation.clone(); SwingUtilities.convertPointFromScreen(componentLocation, popupSource); if (tipWindow == null && popupSource.contains(componentLocation)) { // StaticDebug.debug("DND POPUP: Mouse is inside popupSource and popup is not shown"); JToolTip tip = popupSource.createToolTip(); tip.setTipText(reason); PopupFactory popupFactory = PopupFactory.getSharedInstance(); mouseX = screenLocation.x; mouseY = screenLocation.y; // StaticDebug.debug("DND POPUP: show popup at "+mouseX+","+mouseY+" and start hide timer"); tipWindow = popupFactory.getPopup(popupSource, tip, mouseX, mouseY); tipWindow.show(); hideTimer.restart(); } }
Example 10
Source File: ToolTipManagerEx.java From netbeans with Apache License 2.0 | 4 votes |
protected void showTipWindow() { if(insideComponent == null || !insideComponent.isShowing()) return; cancelled = false; LOG.fine("cancelled=false"); //NOI18N for (Container p = insideComponent.getParent(); p != null; p = p.getParent()) { if (p instanceof JPopupMenu) break; if (p instanceof Window) { if (!((Window)p).isFocused()) { return; } break; } } if (enabled) { Dimension size; // Just to be paranoid hideTipWindow(); tip = createToolTip(); tip.setTipText(toolTipText); size = tip.getPreferredSize(); Point location = provider.getToolTipLocation( mouseEvent.getPoint(), size ); // we do not adjust x/y when using awt.Window tips if (popupRect == null){ popupRect = new Rectangle(); } popupRect.setBounds( location.x, location.y, size.width, size.height ); PopupFactory popupFactory = PopupFactory.getSharedInstance(); tipWindow = popupFactory.getPopup(insideComponent, tip, location.x, location.y); tipWindow.show(); Window componentWindow = SwingUtilities.windowForComponent( insideComponent); window = SwingUtilities.windowForComponent(tip); if (window != null && window != componentWindow) { window.addMouseListener(this); } else { window = null; } Toolkit.getDefaultToolkit().addAWTEventListener( getAWTListener(), AWTEvent.KEY_EVENT_MASK ); tipShowing = true; } }
Example 11
Source File: PopupMenuUI.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 12
Source File: PopupMenuUI.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 13
Source File: PopupMenuUI.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 14
Source File: PopupMenuUI.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 15
Source File: PopupMenuUI.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 16
Source File: PopupMenuUI.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 17
Source File: PopupMenuUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 18
Source File: PopupMenuUI.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 19
Source File: PopupMenuUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }
Example 20
Source File: PopupMenuUI.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Returns the <code>Popup</code> that will be responsible for * displaying the <code>JPopupMenu</code>. * * @param popup JPopupMenu requesting Popup * @param x Screen x location Popup is to be shown at * @param y Screen y location Popup is to be shown at. * @return Popup that will show the JPopupMenu * @since 1.4 */ public Popup getPopup(JPopupMenu popup, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popup.getInvoker(), popup, x, y); }