当前位置: 首页>>代码示例>>Java>>正文


Java PopupFactory类代码示例

本文整理汇总了Java中javax.swing.PopupFactory的典型用法代码示例。如果您正苦于以下问题:Java PopupFactory类的具体用法?Java PopupFactory怎么用?Java PopupFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PopupFactory类属于javax.swing包,在下文中一共展示了PopupFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showPopup

import javax.swing.PopupFactory; //导入依赖的package包/类
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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TextValueCompleter.java

示例2: moreButtonActionPerformed

import javax.swing.PopupFactory; //导入依赖的package包/类
/**
     * 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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:KeymapPanel.java

示例3: changeButtonActionPerformed

import javax.swing.PopupFactory; //导入依赖的package包/类
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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ShortcutCellPanel.java

示例4: showPopup

import javax.swing.PopupFactory; //导入依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProfilerTableHover.java

示例5: doSelect

import javax.swing.PopupFactory; //导入依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ButtonPopupSwitcher.java

示例6: showToolTip

import javax.swing.PopupFactory; //导入依赖的package包/类
private void showToolTip(boolean flag) {
    try {
        if (flag) {
            int qtd = heroi.getDeck().size();
            String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
                    ? "1 card" : qtd + " cards");
            Point p = getLocationOnScreen();
            JToolTip tip = createToolTip();
            tip.setTipText(txt);
            PopupFactory popupFactory = PopupFactory.getSharedInstance();
            tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
            tooltip.show();
        } else {
            tooltip.hide();
        }
    } catch (Exception ex) {
        //ignorar
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:20,代码来源:DeckBack.java

示例7: showToolTip

import javax.swing.PopupFactory; //导入依赖的package包/类
private void showToolTip(boolean flag) {
    try {
        if (flag) {
            int qtd = heroi.getMao().size();
            String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
                    ? "1 card" : qtd + " cards");
            Point p = getLocationOnScreen();
            JToolTip tip = createToolTip();
            tip.setTipText(txt);
            PopupFactory popupFactory = PopupFactory.getSharedInstance();
            tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
            tooltip.show();
        } else {
            tooltip.hide();
        }
    } catch (Exception ex) {
        //ignorar
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:20,代码来源:MaoBack.java

示例8: showPopup

import javax.swing.PopupFactory; //导入依赖的package包/类
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();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:LayoutPopupManager.java

示例9: onStart

import javax.swing.PopupFactory; //导入依赖的package包/类
@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();
}
 
开发者ID:sylvain121,项目名称:Xpra-client-android,代码行数:17,代码来源:SwingPopup.java

示例10: showCRPopup

import javax.swing.PopupFactory; //导入依赖的package包/类
private void showCRPopup() {
    carringtonPanel.setTime(time);

    // get position for popup
    int x = crPopupButton.getLocationOnScreen().x;
    int y = crPopupButton.getLocationOnScreen().y + crPopupButton.getSize().height;

    // create popup
    PopupFactory factory = PopupFactory.getSharedInstance();

    // correct position of popup when it does not fit into screen area
    x = x + carringtonPanel.getSize().width > Toolkit.getDefaultToolkit().getScreenSize().width ? Toolkit.getDefaultToolkit().getScreenSize().width - carringtonPanel.getSize().width : x;
    x = x < 0 ? 0 : x;
    y = y + carringtonPanel.getSize().height > Toolkit.getDefaultToolkit().getScreenSize().height ? crPopupButton.getLocationOnScreen().y - carringtonPanel.getSize().height : y;
    y = y < 0 ? 0 : y;

    // show popup
    crPopup = factory.getPopup(crPopupButton, carringtonPanel, x, y);
    crPopup.show();
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:21,代码来源:JHVCarringtonPicker.java

示例11: actionPerformed

import javax.swing.PopupFactory; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    JToggleButton b = (JToggleButton) e.getSource();
    if (!b.isSelected() && volumePopup != null) {
        volumePopup.hide();
        volumePopup = null;
    } else {
        Dimension panelSize = volumePanel.getPreferredSize();
        // Right-align it with the volume button, so it pops up just above it
        Point location = new Point(0 - panelSize.width + getPreferredSize().width,
                0 - panelSize.height);
        SwingUtilities.convertPointToScreen(location, PopupVolumeButton.this);
        volumePopup = PopupFactory.getSharedInstance().getPopup(PopupVolumeButton.this,
                volumePanel, location.x, location.y);
        // Remove the slider value from the top of the slider
        Object paintValue = UIManager.put("Slider.paintValue", Boolean.FALSE);
        volumePopup.show();
        UIManager.put("Slider.paintValue", paintValue);
    }
}
 
开发者ID:gstreamer-java,项目名称:gstreamer1.x-java,代码行数:20,代码来源:PopupVolumeButton.java

示例12: showPanel

import javax.swing.PopupFactory; //导入依赖的package包/类
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 - 295) {
		x = size.width - 295;
	}
	if (y < size.height - 170) {
	} else {
		y -= 188;
	}
	pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y);
	pop.show();
	isShow = true;
}
 
开发者ID:Disguiser-w,项目名称:SE2,代码行数:24,代码来源:DateChooser.java

示例13: showPermanent

import javax.swing.PopupFactory; //导入依赖的package包/类
private void showPermanent()
{
	if(permanentPopup != null)
	{
		if(permanentToolTip == toolTip)
			return;
		permanentPopup.hide();
		permanentPopup = null;
		permanentToolTip = null;
	}
	
	permanentToolTip = new AddonToolTip(toolTip);
	permanentToolTip.setTemporary(false);
	Point location = toolTip.getLocationOnScreen();
	PopupFactory popupFactory = PopupFactory.getSharedInstance();
	
	permanentPopup = popupFactory.getPopup(toolTip.getComponent(), permanentToolTip, location.x, location.y);
	
	permanentPopup.show();
}
 
开发者ID:langmo,项目名称:youscope,代码行数:21,代码来源:BasicAddonToolTipUI.java

示例14: setPopupFactory

import javax.swing.PopupFactory; //导入依赖的package包/类
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);
		}
	});
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:25,代码来源:CustomPopupFactory.java

示例15: showPopup

import javax.swing.PopupFactory; //导入依赖的package包/类
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();
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:27,代码来源:LayoutPopupManager.java


注:本文中的javax.swing.PopupFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。