本文整理汇总了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());
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
示例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
}
}
示例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
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
});
}
示例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();
}