Java 类javax.swing.PopupFactory 实例源码

项目:incubator-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());
    }
}
项目:incubator-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();
}
项目:incubator-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();
    }
}
项目:incubator-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();
}
项目:incubator-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();
}
项目:hearthstone    文件:DeckBack.java   
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
    }
}
项目:hearthstone    文件:MaoBack.java   
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
    }
}
项目: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();
}
项目:Xpra-client-android    文件: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();
}
项目:JHelioviewer-SWHV    文件:JHVCarringtonPicker.java   
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();
}
项目:gstreamer1.x-java    文件:PopupVolumeButton.java   
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);
    }
}
项目:SE2    文件:DateChooser.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 - 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;
}
项目:youscope    文件:BasicAddonToolTipUI.java   
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();
}
项目: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);
        }
    });
}
项目:Xpra-client-android    文件: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();
}
项目: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();
}
项目:logisim-evolution    文件: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();
}
项目:ProyectoLogisim    文件: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();
}
项目:incubator-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);
}
项目:incubator-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;
}
项目:incubator-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;
}
项目:incubator-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");
}
项目:incubator-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;
}
项目:rapidminer    文件:RoundedPopupFactory.java   
public static void install() {
    PopupFactory factory = PopupFactory.getSharedInstance();
    if (factory instanceof RoundedPopupFactory) {
        return;
    }
    PopupFactory.setSharedInstance(new RoundedPopupFactory(factory));
}
项目:rapidminer    文件:RoundedPopupFactory.java   
public static void uninstall() {
    PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof RoundedPopupFactory)) {
        return;
    }
    PopupFactory stored = ((RoundedPopupFactory) factory).storedFactory;
    PopupFactory.setSharedInstance(stored);
}
项目: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;
}
项目: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);
  }
}
项目: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);
  }
}
项目:pumpernickel    文件:AppletPopupFactory.java   
public static void initialize() {
    if(initialized)
        return;
    try {
        PopupFactory oldFactory = PopupFactory.getSharedInstance();
        PopupFactory.setSharedInstance(new AppletPopupFactory(oldFactory));
    } finally {
        initialized = true;
    }
}
项目: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();
    }
}
项目:JHelioviewer-SWHV    文件:JHVCalendarDatePicker.java   
/**
 * Opens an new popup window where the user can select a date.
 */
private void showCalPopup() {
    // set up the popup content
    jhvCalendar.setDate(calendar.getTime());

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

    // create popup
    PopupFactory factory = PopupFactory.getSharedInstance();
    calPopup = factory.getPopup(calPopupButton, jhvCalendar, x, y);
    calPopup.show();

    jhvCalendar.resizeSelectionPanel();

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

    calPopup.hide();

    // show popup
    calPopup = factory.getPopup(calPopupButton, jhvCalendar, x, y);
    calPopup.show();
}
项目: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());
}
项目:LS-jsampler    文件:JSVolumeEditorPopup.java   
public void
show() {
    if(popup != null) {
        popup.hide();
    }

    shouldCommit = true;

    Point p = owner.getLocationOnScreen();
    int h = owner.getHeight();
    popup = PopupFactory.getSharedInstance().getPopup(owner, spinner, p.x, p.y + h);
    popup.show();
    JComponent c = spinner.getEditor();
    ((JSpinner.DefaultEditor)c).getTextField().requestFocus();
}
项目:rapidminer-studio    文件:RoundedPopupFactory.java   
public static void install() {
    PopupFactory factory = PopupFactory.getSharedInstance();
    if (factory instanceof RoundedPopupFactory) {
        return;
    }
    PopupFactory.setSharedInstance(new RoundedPopupFactory(factory));
}
项目: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);
}
项目:bigtable-sql    文件:Application.java   
/**
 * Setup applications Look and Feel.
 */
private void setupLookAndFeel(ApplicationArguments args)
{
    /* 
     * Don't prevent the user from overriding the laf is they choose to use 
     * Swing's default laf prop 
     */
    String userSpecifiedOverride = System.getProperty("swing.defaultlaf");
    if (userSpecifiedOverride != null && !"".equals(userSpecifiedOverride)) { return; }

    String lafClassName =
        args.useNativeLAF() ? UIManager.getSystemLookAndFeelClassName() : MetalLookAndFeel.class.getName();

    if (!args.useDefaultMetalTheme())
    {
        MetalLookAndFeel.setCurrentTheme(new AllBluesBoldMetalTheme());
    }

    try
    {
        // The following is a work-around for the problem on Mac OS X where
        // the Apple LAF delegates to the Swing Popup factory but then
        // tries to set a 90% alpha on the underlying Cocoa window, which
        // will always be null if you're using JGoodies L&F
        // see http://www.caimito.net/pebble/2005/07/26/1122392314480.html#comment1127522262179
        // This has no effect on Linux/Windows
        PopupFactory.setSharedInstance(new PopupFactory());

        UIManager.setLookAndFeel(lafClassName);
    }
    catch (Exception ex)
    {
        // i18n[Application.error.setlaf=Error setting LAF]
        s_log.error(s_stringMgr.getString("Application.error.setlaf"), ex);
    }
}
项目:confluence.keygen    文件:ShadowPopupFactory.java   
public static void install()
/*  22:    */   {
/*  23:117 */     if (LookUtils.IS_OS_MAC) {
/*  24:118 */       return;
/*  25:    */     }
/*  26:121 */     PopupFactory factory = PopupFactory.getSharedInstance();
/*  27:122 */     if ((factory instanceof ShadowPopupFactory)) {
/*  28:123 */       return;
/*  29:    */     }
/*  30:125 */     PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
/*  31:    */   }
项目:confluence.keygen    文件:ShadowPopupFactory.java   
public static void uninstall()
/*  34:    */   {
/*  35:135 */     PopupFactory factory = PopupFactory.getSharedInstance();
/*  36:136 */     if (!(factory instanceof ShadowPopupFactory)) {
/*  37:137 */       return;
/*  38:    */     }
/*  39:139 */     PopupFactory stored = ((ShadowPopupFactory)factory).storedFactory;
/*  40:140 */     PopupFactory.setSharedInstance(stored);
/*  41:    */   }
项目:javamelody    文件:ShadowPopupFactory.java   
/**
 * Installs the ShadowPopupFactory as the shared popup factory
 * on non-Mac platforms. Also stores the previously set factory,
 * so that it can be restored in <code>#uninstall</code>.<p>
 *
 * In some Mac Java environments the popup factory throws
 * a NullPointerException when we call <code>#getPopup</code>.<p>
 *
 * The Mac case shows that we may have problems replacing
 * non PopupFactory instances. Therefore we should consider
 * replacing only instances of PopupFactory.
 *
 * @see #uninstall()
 */
public static void install() {
    final String os = System.getProperty("os.name");
    final boolean macintosh = os != null && os.indexOf("Mac") != -1;
    if (macintosh) {
        return;
    }

    final PopupFactory factory = PopupFactory.getSharedInstance();
    if (factory instanceof ShadowPopupFactory) {
        return;
    }

    PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
}
项目:javamelody    文件:ShadowPopupFactory.java   
/**
 * Uninstalls the ShadowPopupFactory and restores the original
 * popup factory as the new shared popup factory.
 *
 * @see #install()
 */
public static void uninstall() {
    final PopupFactory factory = PopupFactory.getSharedInstance();
    if (!(factory instanceof ShadowPopupFactory)) {
        return;
    }

    final PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory;
    PopupFactory.setSharedInstance(stored);
}