当前位置: 首页>>代码示例>>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;未经允许,请勿转载。