本文整理汇总了Java中javax.swing.Popup类的典型用法代码示例。如果您正苦于以下问题:Java Popup类的具体用法?Java Popup怎么用?Java Popup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Popup类属于javax.swing包,在下文中一共展示了Popup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPopup
import javax.swing.Popup; //导入依赖的package包/类
private void initPopup(Component owner, Component contents, int x, int y, Popup popup) {
this.owner = owner;
this.contents = contents;
this.popup = popup;
this.x = x;
this.y = y;
boolean mac = false;
try {
mac = System.getProperty("os.name").toLowerCase().startsWith("mac");
} catch (SecurityException e) {
// do nothing
}
if (mac) {
((JComponent) contents).setBorder(Borders.getPopupMenuBorder());
} else if (((JComponent) contents).getBorder() instanceof DummyBorder) {
if (!((owner instanceof JMenu) && ((JMenu) owner).isTopLevelMenu()) && !((owner.getParent() != null) && (owner.getParent() instanceof javax.swing.JToolBar)) && !((owner != null) && (owner instanceof javax.swing.JComboBox))) {
((JComponent) contents).setBorder(Borders.getShadowedPopupMenuBorder());
} else {
((JComponent) contents).setBorder(Borders.getPopupBorder());
}
}
}
示例2: getPopup
import javax.swing.Popup; //导入依赖的package包/类
@Override
public Popup getPopup(Component owner, Component contents,
int x, int y) throws IllegalArgumentException {
assert owner instanceof JComponent;
Dimension d = contents.getPreferredSize();
Container c = ((JComponent) owner).getTopLevelAncestor();
if (c == null) {
throw new IllegalArgumentException ("Not onscreen: " + owner);
}
Point p = new Point (x, y);
SwingUtilities.convertPointFromScreen(p, c);
Rectangle r = new Rectangle (p.x, p.y, d.width, d.height);
if (c.getBounds().contains(r)) {
//XXX need API to determine if editor area comp is heavyweight,
//and if so, return a "medium weight" popup of a java.awt.Component
//that embeds the passed contents component
return new LWPopup (owner, contents, x, y);
} else {
return new HWPopup (owner, contents, x, y);
}
}
示例3: initPopup
import javax.swing.Popup; //导入依赖的package包/类
private void initPopup(Component owner, Component contents, int x, int y, Popup popup) {
this.owner = owner;
this.contents = contents;
this.popup = popup;
this.x = x;
this.y = y;
boolean mac = false;
try {
mac = System.getProperty("os.name").toLowerCase().startsWith("mac");
} catch (SecurityException e) {
// do nothing
}
if (mac) {
((JComponent) contents).setBorder(Borders.getPopupMenuBorder());
} else if (((JComponent) contents).getBorder() instanceof DummyBorder) {
if (!((owner instanceof JMenu) && ((JMenu) owner).isTopLevelMenu())
&& !((owner.getParent() != null) && (owner.getParent() instanceof javax.swing.JToolBar))
&& !((owner != null) && (owner instanceof javax.swing.JComboBox))) {
((JComponent) contents).setBorder(Borders.getShadowedPopupMenuBorder());
} else {
((JComponent) contents).setBorder(Borders.getPopupBorder());
}
}
}
示例4: isFocusInside
import javax.swing.Popup; //导入依赖的package包/类
/**
* Checks if the focus is still on this component or its child components.
*/
private boolean isFocusInside(Object newFocusedComp) {
if (newFocusedComp instanceof Popup) {
return true;
}
if (newFocusedComp instanceof Component && !SwingUtilities.isDescendingFrom((Component) newFocusedComp, this)) {
// Check if focus is on other window
if (containingWindow == null) {
return false;
}
Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
// if focus is on other window return true
if (containingWindow == focusedWindow) {
return false;
}
}
return true;
}
示例5: showPopup
import javax.swing.Popup; //导入依赖的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();
}
示例6: getPopup
import javax.swing.Popup; //导入依赖的package包/类
@Override
public Popup getPopup(Component owner, Component contents, int x, int y)
throws IllegalArgumentException {
Component[] hierarchy = getHierarchy(owner);
for(int a = hierarchy.length-1; a>=0; a--) {
if(hierarchy[a] instanceof JApplet &&
contents instanceof JComponent) {
return new AppletPopup( (JApplet)hierarchy[a], owner, (JComponent)contents, x, y);
/* Unfortunately we can't simply check against a java.awt.Frame,
* because applets can be embedded in a
* sun.plugin2.main.client.PluginEmbeddedFrame.
*/
//} else if(hierarchy[a] instanceof Frame) {
} else if(hierarchy[a] instanceof JFrame) {
return oldFactory.getPopup(owner, contents, x, y);
}
}
return oldFactory.getPopup(owner, contents, x, y);
}
示例7: initPopup
import javax.swing.Popup; //导入依赖的package包/类
private void initPopup(Component owner, Component contents, int x, int y, Popup popup) {
this.owner = owner;
this.contents = contents;
this.popup = popup;
this.x = x;
this.y = y;
boolean mac = false;
try {
mac = System.getProperty("os.name").toLowerCase().startsWith("mac");
} catch (SecurityException e) {
// do nothing
}
if (mac) {
((JComponent) contents).setBorder(Borders.getPopupMenuBorder());
} else if (((JComponent) contents).getBorder() instanceof DummyBorder) {
if ((owner != null) //
&& (((owner instanceof JMenu) && ((JMenu) owner).isTopLevelMenu()) //
|| ((owner.getParent() != null) && (owner.getParent() instanceof javax.swing.JToolBar)) //
|| (owner instanceof javax.swing.JComboBox))) {
((JComponent) contents).setBorder(Borders.getPopupBorder());
} else {
((JComponent) contents).setBorder(Borders.getShadowedPopupMenuBorder());
}
}
}
示例8: PopupListenerHandler
import javax.swing.Popup; //导入依赖的package包/类
/**
* Creates a new {@link PopupListenerHandler} for the given {@link Popup},
* glass pane and owning frame associated with the {@link Popup}. A
* {@link ComponentListener} and {@link MouseAdapter} is also created to be
* attached to the glass pane and owning frame to determine when to cleanup
* the {@link Popup}.
*
* @param popup
* The {@link Popup} this class handles.
* @param glassPane
* The {@link JComponent} that mouse clicks should be listened
* for to figure out when to close the {@link Popup}.
* @param owningFrame
* The {@link Component} that the {@link Popup} belongs to.
*/
public PopupListenerHandler(final Popup popup, final JComponent glassPane, final Component owningFrame) {
this.popup = popup;
this.glassPane = glassPane;
this.owningFrame = owningFrame;
clickListener = new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
cleanup();
}
};
resizeListener = new ComponentAdapter() {
public void componentMoved(ComponentEvent e) {
cleanup();
}
};
}
示例9: setPopupFactory
import javax.swing.Popup; //导入依赖的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);
}
});
}
示例10: getInstance
import javax.swing.Popup; //导入依赖的package包/类
static Popup getInstance(Component owner, Component contents, int x, int y,
Popup delegate) {
final ShadowPopup result;
synchronized (ShadowPopup.class) {
if (cache == null) {
cache = new ArrayList<>(MAX_CACHE_SIZE);
}
if (!cache.isEmpty()) {
result = cache.remove(0);
} else {
result = new ShadowPopup();
}
}
result.reset(owner, contents, x, y, delegate);
return result;
}
示例11: getPopup
import javax.swing.Popup; //导入依赖的package包/类
public Popup getPopup(Component owner, Component contents,
int x, int y) throws IllegalArgumentException {
assert owner instanceof JComponent;
Dimension d = contents.getPreferredSize();
Container c = ((JComponent) owner).getTopLevelAncestor();
if (c == null) {
throw new IllegalArgumentException ("Not onscreen: " + owner);
}
Point p = new Point (x, y);
SwingUtilities.convertPointFromScreen(p, c);
Rectangle r = new Rectangle (p.x, p.y, d.width, d.height);
if (c.getBounds().contains(r)) {
//XXX need API to determine if editor area comp is heavyweight,
//and if so, return a "medium weight" popup of a java.awt.Component
//that embeds the passed contents component
return new LWPopup (owner, contents, x, y);
} else {
return APPLE_HEAVYWEIGHT ?
(Popup) new HWPopup (owner, contents, x, y) :
(Popup) new NullPopup();
}
}
示例12: showPopup
import javax.swing.Popup; //导入依赖的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();
}
示例13: showPopup
import javax.swing.Popup; //导入依赖的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();
}
示例14: isFocusInside
import javax.swing.Popup; //导入依赖的package包/类
/**
* Checks if the focus is still on this component or its child components.
*/
private boolean isFocusInside(Object newFocusedComp) {
if(newFocusedComp instanceof Popup) {
return true;
}
if (newFocusedComp instanceof Component && !SwingUtilities.isDescendingFrom((Component)newFocusedComp, this)) {
//Check if focus is on other window
if (containingWindow == null) {
return false;
}
Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
// if focus is on other window return true
if (containingWindow == focusedWindow) {
return false;
}
}
return true;
}
示例15: getPopup
import javax.swing.Popup; //导入依赖的package包/类
@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);
}