类javax.swing.PopupFactory源码实例Demo

下面列出了怎么用javax.swing.PopupFactory的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FlatLaf   文件: FlatPopupFactory.java
/**
 * There is no API in Java 8 to force creation of heavy weight popups,
 * but it is possible with reflection. Java 9 provides a new method.
 *
 * When changing FlatLaf system requirements to Java 9+,
 * then this method can be replaced with:
 *    return getPopup( owner, contents, x, y, true );
 */
private Popup getHeavyWeightPopup( Component owner, Component contents, int x, int y )
	throws IllegalArgumentException
{
	try {
		if( SystemInfo.IS_JAVA_9_OR_LATER ) {
			if( java9getPopupMethod == null ) {
				java9getPopupMethod = PopupFactory.class.getDeclaredMethod(
					"getPopup", Component.class, Component.class, int.class, int.class, boolean.class );
			}
			return (Popup) java9getPopupMethod.invoke( this, owner, contents, x, y, true );
		} else {
			// Java 8
			if( java8getPopupMethod == null ) {
				java8getPopupMethod = PopupFactory.class.getDeclaredMethod(
					"getPopup", Component.class, Component.class, int.class, int.class, int.class );
				java8getPopupMethod.setAccessible( true );
			}
			return (Popup) java8getPopupMethod.invoke( this, owner, contents, x, y, /*HEAVY_WEIGHT_POPUP*/ 2 );
		}
	} catch( NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException ex ) {
		// ignore
		return null;
	}
}
 
源代码2 项目: netbeans   文件: TextValueCompleter.java
private void showPopup() {
    hidePopup();
    if (completionListModel.getSize() == 0) {
        return;
    }
    // figure out where the text field is,
    // and where its bottom left is
    java.awt.Point los = field.getLocationOnScreen();
    int popX = los.x;
    int popY = los.y + field.getHeight();
    popup = PopupFactory.getSharedInstance().getPopup(field, listScroller, popX, popY);
    field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),ACTION_HIDEPOPUP);
    field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),ACTION_FILLIN);
    popup.show();
    if (completionList.getSelectedIndex() != -1) {
        completionList.ensureIndexIsVisible(completionList.getSelectedIndex());
    }
}
 
源代码3 项目: netbeans   文件: KeymapPanel.java
/**
     * Shows popup with ESC and TAB keys
     */
    private void moreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moreButtonActionPerformed
        if (searchPopup != null) {
            return;
        }
        JComponent tf = (JComponent) evt.getSource();
        Point p = new Point(tf.getX(), tf.getY());
        SwingUtilities.convertPointToScreen(p, this);
        Rectangle usableScreenBounds = Utilities.getUsableScreenBounds();
        if (p.x + specialkeyList.getWidth() > usableScreenBounds.width) {
            p.x = usableScreenBounds.width - specialkeyList.getWidth();
        }
        if (p.y + specialkeyList.getHeight() > usableScreenBounds.height) {
            p.y = usableScreenBounds.height - specialkeyList.getHeight();
        }
        //show special key popup
        searchPopup = PopupFactory.getSharedInstance().getPopup(this, specialkeyList, p.x, p.y);
        searchPopup.show();
}
 
源代码4 项目: netbeans   文件: ShortcutCellPanel.java
private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
    JComponent tf = changeButton;
    Point p = new Point(tf.getX(), tf.getY());
    SwingUtilities.convertPointToScreen(p, this);
    //show special key popup
    if (popup == null) {
        changeButton.setText(""); // NOI18N
        changeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/more_closed.png")));
        if (Utilities.isUnix()) {
            // #156869 workaround, force HW for Linux
            popup = PopupFactory.getSharedInstance().getPopup(null, specialkeyList, p.x, p.y + tf.getHeight());
        } else {
            popup = factory.getPopup(this, specialkeyList, p.x, p.y + tf.getHeight());
        }
        popup.show();
    } else {
        changeButton.setText(""); // NOI18N
        changeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/more_opened.png")));
        hidePopup();
    }
}
 
源代码5 项目: netbeans   文件: ProfilerTableHover.java
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();
}
 
源代码6 项目: netbeans   文件: ButtonPopupSwitcher.java
private void doSelect(JComponent owner) {
    invokingComponent = owner;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    
    Toolkit.getDefaultToolkit().addAWTEventListener(this,
            AWTEvent.MOUSE_EVENT_MASK
            | AWTEvent.KEY_EVENT_MASK);
    popup = PopupFactory.getSharedInstance().getPopup(
            invokingComponent, pTable, x, y);
    popup.show();
    shown = true;
    invocationTime = System.currentTimeMillis();
}
 
源代码7 项目: Logisim   文件: LayoutPopupManager.java
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();
}
 
源代码8 项目: visualvm   文件: ProfilerTableHover.java
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();
}
 
private void enforceHeavyWeightComponents() {
	if (!couldEnforceHeavyWeightComponents) {
		return;
	}

	AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
		try {
			Method setPopupTypeMethod = PopupFactory.class.getDeclaredMethod("setPopupType", int.class);
			setPopupTypeMethod.setAccessible(true);
			// 2 is the heavyweight constant
			setPopupTypeMethod.invoke(this, 2);
		} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException aE) {
			// if it fails once, it will fail every time. Do not try again
			couldEnforceHeavyWeightComponents = false;
		}
		return null;
	});
}
 
源代码10 项目: WorldGrower   文件: CustomPopupFactory.java
public static void setPopupFactory() {
	PopupFactory.setSharedInstance(new PopupFactory() {

		@Override
		public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException {
			if (contents instanceof JToolTip) {
				JToolTip toolTip = (JToolTip)contents;
				int width = (int) toolTip.getPreferredSize().getWidth();
				
				GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
				int screenWidth = gd.getDisplayMode().getWidth();
				
				// if there is enough room, move tooltip to the right to have enough room
				// for large tooltips.
				// this way they don't hinder mouse movement and make it possible to easily
				// view multiple tooltips of items.
				if (x + width + TOOLTIP_X_OFFSET < screenWidth) {
					x += TOOLTIP_X_OFFSET;
				}
			}
			return super.getPopup(owner, contents, x, y);
		}
	});
}
 
源代码11 项目: xpra-client   文件: SwingPopup.java
@Override
protected void onStart(NewWindow wnd) {
	Window window = null;
	int offsetX = 0;
	int offsetY = 0;
	if(owner != null) {
		window = owner.window;
		offsetX = owner.offsetX;
		offsetY = owner.offsetY;
	}
	canvas = new XpraCanvas(this);
	canvas.setCustomRoot(window);
	canvas.setPreferredSize(new Dimension(wnd.getWidth(), wnd.getHeight()));
	popup = PopupFactory.getSharedInstance().getPopup(window, canvas, wnd.getX() + offsetX, wnd.getY() + offsetY);
	popup.show();
}
 
源代码12 项目: FlatLaf   文件: FlatLaf.java
@Override
public void uninitialize() {
	// remove desktop property listener
	if( desktopPropertyListener != null ) {
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		toolkit.removePropertyChangeListener( desktopPropertyName, desktopPropertyListener );
		if( desktopPropertyName2 != null )
			toolkit.removePropertyChangeListener( desktopPropertyName2, desktopPropertyListener );
		toolkit.removePropertyChangeListener( DESKTOPFONTHINTS, desktopPropertyListener );
		desktopPropertyName = null;
		desktopPropertyName2 = null;
		desktopPropertyListener = null;
	}

	// uninstall popup factory
	if( oldPopupFactory != null ) {
		PopupFactory.setSharedInstance( oldPopupFactory );
		oldPopupFactory = null;
	}

	// uninstall mnemonic handler
	if( mnemonicHandler != null ) {
		mnemonicHandler.uninstall();
		mnemonicHandler = null;
	}

	// restore default link color
	new HTMLEditorKit().getStyleSheet().addRule( "a { color: blue; }" );
	postInitialization = null;

	// restore enable/disable window decorations
	if( oldFrameWindowDecorated != null ) {
		JFrame.setDefaultLookAndFeelDecorated( oldFrameWindowDecorated );
		JDialog.setDefaultLookAndFeelDecorated( oldDialogWindowDecorated );
		oldFrameWindowDecorated = null;
		oldDialogWindowDecorated = null;
	}

	super.uninitialize();
}
 
源代码13 项目: arcusplatform   文件: Toast.java
public Toast(Component comp, Point toastLocation, String msg, long forDuration) {
    this.component = comp;
    this.location = toastLocation;
    this.message = msg;
    this.duration = forDuration;

    if(this.component != null)
    {

        if(this.location == null)
        {
            this.location = component.getLocationOnScreen();
        }

        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                Popup view = null;
                try
                {
                    Label tip = new Label(message);
                    tip.setForeground(Color.black);
                    tip.setBackground(Color.white);
                    view = PopupFactory.getSharedInstance().getPopup(component, tip , location.x + 30, location.y + component.getHeight() + 5);
                    view.show();
                    Thread.sleep(duration);
                } catch (InterruptedException ex)
                {
                    Logger.getLogger(Toast.class.getName()).log(Level.SEVERE, null, ex);
                }
                finally
                {
                    view.hide();
                }
            }
        }).start();
    }
}
 
源代码14 项目: netbeans   文件: VisualDesignerPopupMenuUI.java
@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);
}
 
源代码15 项目: netbeans   文件: CompletionLayoutPopup.java
/**
 * 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;
}
 
源代码16 项目: netbeans   文件: InnerPanelSupport.java
@Override
public void mouseMoved(MouseEvent e) {
    Point p = e.getPoint();
    int col = listClasses.columnAtPoint(p);
    int row = listClasses.rowAtPoint(p);
    
    if (col < 0 || row < 0) {
        hidePopup();
        return;
    }
    if (col == currentCol && row == currentRow) {
        // the tooltip is (probably) shown, do not create again
        return;
    }
    Rectangle cellRect = listClasses.getCellRect(row, col, false);
    Point pt = cellRect.getLocation();
    SwingUtilities.convertPointToScreen(pt, listClasses);
    
    RenderedImage ri = new RenderedImage();
    if (!updateTooltipImage(ri, row, col)) {
        return;
    }
    ri.addMouseListener(this);
    
    Popup popup = PopupFactory.getSharedInstance().getPopup(listClasses, ri, pt.x, pt.y);
    popupContents = ri;
    currentPopup = popup;
    currentCol = col;
    currentRow = row;
    popup.show();
    System.err.println("Hello");
}
 
源代码17 项目: netbeans   文件: CompletionLayoutPopup.java
/**
 * 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;
}
 
源代码18 项目: netbeans   文件: CompletionLayoutPopup.java
/**
 * 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;
}
 
源代码19 项目: SimpleERP   文件: Chooser.java
private void showPanel(Component owner) {
    if (pop != null) pop.hide();
    Point show = new Point(0, showDate.getHeight());
    SwingUtilities.convertPointToScreen(show, showDate);
    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
    int x = show.x;
    int y = show.y;
    if (x < 0) x = 0;
    if (x > size.width - 212) x = size.width - 212;
    if (y > size.height - 167) y -= 165;
    pop = PopupFactory.getSharedInstance().getPopup(owner, calendarPanel, x, y);
    pop.show();
    isShow = true;
}
 
源代码20 项目: gate-core   文件: LuceneDataStoreSearchGUI.java
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);
  }
}
 
源代码21 项目: gate-core   文件: LuceneDataStoreSearchGUI.java
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);
  }
}
 
源代码22 项目: pumpernickel   文件: JPopover.java
/**
 * Create a new QPopup to display this popover's {@link #getContents()}.
 */
protected QPopup createPopup() {
	PopupFactory pf = PopupFactory.getSharedInstance();
	QPopupFactory qpf = null;
	if (pf instanceof QPopupFactory) {
		qpf = (QPopupFactory) pf;
	} else {
		qpf = new QPopupFactory(pf);
	}
	return qpf.getQPopup(getOwner(), popupTarget, getContents());
}
 
源代码23 项目: jdk8u_jdk   文件: Popup401.java
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();
    }
}
 
源代码24 项目: jdk8u_jdk   文件: JDialog741.java
public void start() {

        System.setProperty("jbre.popupwindow.settype", "true");

        jFrame = new JFrame("Wrong popup z-order");
        jFrame.setSize(200, 200);
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JPanel jPanel = new JPanel();
        jPanel.setPreferredSize(new Dimension(200, 200));

        Popup popup = PopupFactory.getSharedInstance().getPopup(jFrame, jPanel, 100, 100);
        windowAncestor = SwingUtilities.getWindowAncestor(jPanel);
        ((RootPaneContainer) windowAncestor).getRootPane().putClientProperty("SIMPLE_WINDOW", true);
        windowAncestor.setFocusable(true);
        windowAncestor.setFocusableWindowState(true);
        windowAncestor.setAutoRequestFocus(true);

        jFrame.setVisible(true);
        popup.show();


        modalBlocker = new JDialog(windowAncestor, "Modal Blocker");
        modalBlocker.setModal(true);
        modalBlocker.setSize(new Dimension(200, 200));
        modalBlocker.setLocation(200, 200);
        modalBlocker.addWindowListener(new JDialog741Listener());
        modalBlocker.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        modalBlocker.setVisible(true);
    }
 
源代码25 项目: jdk8u_jdk   文件: JDialog705.java
public static void main(String[] args) throws Exception {

        SwingUtilities.invokeAndWait(() -> {
            jFrame = new JFrame("Wrong popup z-order");
            jFrame.setSize(200, 200);

            JPanel jPanel = new JPanel();
            jPanel.setPreferredSize(new Dimension(200, 200));
            jPanel.setBackground(Color.BLACK);

            Popup popup = PopupFactory.getSharedInstance().getPopup(jFrame, jPanel, 100, 100);
            windowAncestor = SwingUtilities.getWindowAncestor(jPanel);
            ((RootPaneContainer) windowAncestor).getRootPane().putClientProperty("SIMPLE_WINDOW", true);
            windowAncestor.setFocusable(true);
            windowAncestor.setFocusableWindowState(true);
            windowAncestor.setAutoRequestFocus(true);

            jFrame.setVisible(true);
            popup.show();


            modalBlocker = new JDialog(windowAncestor, "Modal Blocker");
            modalBlocker.setModal(true);
            modalBlocker.setSize(new Dimension(200, 200));
            modalBlocker.setLocation(200, 200);
            modalBlocker.addWindowListener(new DialogListener());

            modalBlocker.setVisible(true);
        });
    }
 
源代码26 项目: littleluck   文件: LuckPopupMenuUIBundle.java
@Override
protected void installOther(UIDefaults table)
{
    // 使用自定义工厂, 设置Popup为透明, 否则无法使用阴影边框
    // Use a custom factory, set the Popup to be transparent.
    // otherwise you can not use the shadow border.
    PopupFactory.setSharedInstance(new LuckPopupFactory());
}
 
源代码27 项目: rapidminer-studio   文件: RoundedPopupFactory.java
public static void install() {
	PopupFactory factory = PopupFactory.getSharedInstance();
	if (factory instanceof RoundedPopupFactory) {
		return;
	}
	PopupFactory.setSharedInstance(new RoundedPopupFactory(factory));
}
 
源代码28 项目: rapidminer-studio   文件: RoundedPopupFactory.java
public static void uninstall() {
	PopupFactory factory = PopupFactory.getSharedInstance();
	if (!(factory instanceof RoundedPopupFactory)) {
		return;
	}
	PopupFactory stored = ((RoundedPopupFactory) factory).storedFactory;
	PopupFactory.setSharedInstance(stored);
}
 
源代码29 项目: rapidminer-studio   文件: RapidMinerGUI.java
/**
 * This default implementation only setup the tool tip durations. Subclasses might override this
 * method.
 */
protected void setupGUI() throws Exception {
	System.setProperty(BookmarkIO.PROPERTY_BOOKMARKS_DIR, FileSystemService.getUserRapidMinerDir().getAbsolutePath());
	System.setProperty(BookmarkIO.PROPERTY_BOOKMARKS_FILE, ".bookmarks");

	try {
		if (SystemInfoUtilities.getOperatingSystem() == OperatingSystem.OSX) {
			// to support OS Xs menu bar shown in the OS X menu bar,
			// we have to load the default system look and feel
			// to exchange the MenuBarUI from RapidLookAndFeel with the
			// default OS X look and feel UI class.
			// See here for more information:
			// http://www.pushing-pixels.org/2008/07/13/swing-applications-and-mac-os-x-menu-bar.html
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			Map<String, Object> macUIDefaults = new HashMap<>();
			macUIDefaults.put("MenuBarUI", UIManager.get("MenuBarUI"));
			UIManager.setLookAndFeel(new RapidLookAndFeel(macUIDefaults));

			// tooltips are painted behind heavyweight windows (e.g. the native Chromium browser window) on OS X
			// despite the call above of ToolTipManager#setLightWeightPopupEnabled(false);
			// so we force a heavyweight popup factory for OS X
			PopupFactory.setSharedInstance(new HeavyweightOSXPopupFactory());
		} else {
			UIManager.setLookAndFeel(new RapidLookAndFeel());
		}
	} catch (Exception e) {
		LogService.getRoot().log(Level.WARNING, I18N.getMessage(LogService.getRoot().getResourceBundle(),
				"com.rapidminer.gui.RapidMinerGUI.setting_up_modern_look_and_feel_error"), e);
	}

	// needed because of native browser window which otherwise renders above all popup menus
	JPopupMenu.setDefaultLightWeightPopupEnabled(false);
}
 
源代码30 项目: triplea   文件: MapUnitTooltipManager.java
@Override
public void actionPerformed(final ActionEvent e) {
  if (text != null && text.length() > 0) {
    final Point currentPoint = MouseInfo.getPointerInfo().getLocation();
    if (isPointWithinParentBounds(currentPoint)) {
      final PopupFactory popupFactory = PopupFactory.getSharedInstance();
      final JToolTip info = new JToolTip();
      info.setTipText("<html>" + text + "</html>");
      popup = popupFactory.getPopup(parent, info, currentPoint.x + 20, currentPoint.y - 20);
      popup.show();
    }
  }
}
 
 类所在包
 同包方法