當前位置: 首頁>>代碼示例>>Java>>正文


Java PopupFactory.getSharedInstance方法代碼示例

本文整理匯總了Java中javax.swing.PopupFactory.getSharedInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java PopupFactory.getSharedInstance方法的具體用法?Java PopupFactory.getSharedInstance怎麽用?Java PopupFactory.getSharedInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.PopupFactory的用法示例。


在下文中一共展示了PopupFactory.getSharedInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例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:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:25,代碼來源:LayoutPopupManager.java

示例9: show

import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:CompletionLayoutPopup.java

示例10: show

import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:CompletionLayoutPopup.java

示例11: install

import javax.swing.PopupFactory; //導入方法依賴的package包/類
public static void install() {
	PopupFactory factory = PopupFactory.getSharedInstance();
	if (factory instanceof RoundedPopupFactory) {
		return;
	}
	PopupFactory.setSharedInstance(new RoundedPopupFactory(factory));
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:RoundedPopupFactory.java

示例12: uninstall

import javax.swing.PopupFactory; //導入方法依賴的package包/類
public static void uninstall() {
	PopupFactory factory = PopupFactory.getSharedInstance();
	if (!(factory instanceof RoundedPopupFactory)) {
		return;
	}
	PopupFactory stored = ((RoundedPopupFactory) factory).storedFactory;
	PopupFactory.setSharedInstance(stored);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:9,代碼來源:RoundedPopupFactory.java

示例13: addStatistics

import javax.swing.PopupFactory; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:40,代碼來源:LuceneDataStoreSearchGUI.java

示例14: initialize

import javax.swing.PopupFactory; //導入方法依賴的package包/類
public static void initialize() {
	if(initialized)
		return;
	try {
		PopupFactory oldFactory = PopupFactory.getSharedInstance();
		PopupFactory.setSharedInstance(new AppletPopupFactory(oldFactory));
	} finally {
		initialized = true;
	}
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:11,代碼來源:AppletPopupFactory.java

示例15: run

import javax.swing.PopupFactory; //導入方法依賴的package包/類
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();
    }
}
 
開發者ID:JetBrains,項目名稱:jdk8u_jdk,代碼行數:33,代碼來源:Popup401.java


注:本文中的javax.swing.PopupFactory.getSharedInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。