当前位置: 首页>>代码示例>>Java>>正文


Java Popup类代码示例

本文整理汇总了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());
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:24,代码来源:RoundedRectanglePopup.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CustomPopupFactory.java

示例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());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:RoundedRectanglePopup.java

示例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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:PopupPanel.java

示例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();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:LayoutPopupManager.java

示例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);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:21,代码来源:AppletPopupFactory.java

示例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());
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:27,代码来源:RoundedRectanglePopup.java

示例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();
          }
      };
      
  }
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:36,代码来源:PopupListenerHandler.java

示例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);
		}
	});
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:25,代码来源:CustomPopupFactory.java

示例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;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:17,代码来源:ShadowPopupFactory.java

示例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();
    }
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:23,代码来源:ApplePopupFactory.java

示例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();
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:27,代码来源:LayoutPopupManager.java

示例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();
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:25,代码来源:LayoutPopupManager.java

示例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;
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:23,代码来源:PopupPanel.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:VisualDesignerPopupMenuUI.java


注:本文中的javax.swing.Popup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。