當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。