當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。