本文整理汇总了Java中javax.swing.SwingUtilities.convertPointFromScreen方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.convertPointFromScreen方法的具体用法?Java SwingUtilities.convertPointFromScreen怎么用?Java SwingUtilities.convertPointFromScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.convertPointFromScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void refresh() {
Point p = resizingComponent.getLocationOnScreen();
int width = resizingComponent.getWidth();
int height = resizingComponent.getHeight();
p.x += width/2;
p.y += height/2;
lbl.setText( width + " x " + height ); //NOI18N
SwingUtilities.convertPointFromScreen( p, this );
Dimension size = panel.getPreferredSize();
p.x -= size.width/2;
p.y -= size.height/2;
panel.setLocation( p );
panel.setSize( size );
}
示例2: showTooltipWindow
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
*
* @param event
*/
private void showTooltipWindow (MouseEvent event) {
Point p = new Point(event.getPoint());
SwingUtilities.convertPointToScreen(p, this);
Point p2 = new Point(p);
SwingUtilities.convertPointFromScreen(p2, textComponent);
// annotation for target line
AnnotateLine al = null;
if (!elementAnnotations.isEmpty()) {
al = getAnnotateLine(getLineFromMouseEvent(event));
}
/**
* al.getCommitMessage() != null - since commit messages are initialized separately from the AL constructor
*/
if (al != null && al.getCommitMessage() != null) {
TooltipWindow ttw = new TooltipWindow(this, al);
ttw.show(new Point(p.x - p2.x, p.y));
}
}
示例3: paint
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, JComponent c) {
LAFUtilities.setProperties(g, c);
if (c.isOpaque()) {
ImageLibrary.drawTiledImage("image.background.FreeColButton", g, c, null);
}
super.paint(g, c);
AbstractButton a = (AbstractButton) c;
if (a.isRolloverEnabled()) {
Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, c);
boolean rollover = c.contains(p);
if (rollover) {
paintButtonPressed(g, (AbstractButton) c);
}
}
}
示例4: updateClientCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void updateClientCursor() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null) {
/*
* This can happen when multiple graphics device cannot decide
* which graphics device contains the current mouse position
* or on systems without a mouse
*/
return;
}
Point p = pointerInfo.getLocation();
SwingUtilities.convertPointFromScreen(p, this);
Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
if (target != null) {
content.setCursor(target.getCursor());
}
}
示例5: paintComponent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void paintComponent(Graphics g) {
super.paintComponent(g);
//Rectangle bounds = g.getClipBounds();
Point loc = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(loc, this);
g.drawString("Wiimote 0: " + loc.x + ", " + loc.y, 10, 20);
//g.translate(bounds.width / 2, bounds.height / 2);
g.setColor(new Color(255, 0, 0));
g.fillRect(loc.x, loc.y, 5, 5);
}
示例6: update
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void update( Point locationOnScreen ) {
if( null != locationOnScreen ) {
SwingUtilities.convertPointFromScreen( locationOnScreen, content );
lastLocation = locationOnScreen;
horizontalSplit = calculateOrientation();
lastLocation.x = Math.max( 0, lastLocation.x );
lastLocation.y = Math.max( 0, lastLocation.y );
lastLocation.x = Math.min( content.getWidth()-splitterWidth, lastLocation.x );
lastLocation.y = Math.min( content.getHeight()-splitterWidth, lastLocation.y );
content.repaint();
} else {
lastLocation = null;
}
}
示例7: showPopupMenu
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Shows given popup on given coordinations and takes care about the
* situation when menu can exceed screen limits.
* Copied from org.netbeans.core.windows.frames.DefaultContainerImpl
*/
private static void showPopupMenu(JPopupMenu popup, Point p, Component comp) {
SwingUtilities.convertPointToScreen(p, comp);
Dimension popupSize = popup.getPreferredSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (p.x + popupSize.width > screenSize.width) {
p.x = screenSize.width - popupSize.width;
}
if (p.y + popupSize.height > screenSize.height) {
p.y = screenSize.height - popupSize.height;
}
SwingUtilities.convertPointFromScreen(p, comp);
popup.show(comp, p.x, p.y);
}
示例8: mouseReleased
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent me) {
// convert point in case we got triggered by a libraryPanel
Point clickPoint = me.getPoint();
if(me.getSource() instanceof LibraryPanel)
{
clickPoint = new java.awt.Point(me.getLocationOnScreen());
SwingUtilities.convertPointFromScreen(clickPoint, this);
}
// only act if we had an element
if(selected!=null)
{
// repostion element
selected.setOffset(new Point(clickPoint.x-selectedDelta.width,
clickPoint.y-selectedDelta.height));
if(selected.isElementary())
{
selected.setOffset(new Point((clickPoint.x-selectedDelta.width) -((clickPoint.x-selectedDelta.width) % 10),
(clickPoint.y-selectedDelta.height)-((clickPoint.y-selectedDelta.height)% 10)));
}
if(selected.getType()!=Type.PARAMETERS &&
selected.getType()!=Type.LIST &&
selected.getType()!=Type.ITEM)
{
putBack(selected);
}
// something changed
somethingChanged();
}
selected=null;
repaint();
}
示例9: computeTipVisibleBounds
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* Compute the bounds in which the user can move the mouse without the
* tip window disappearing.
*/
private void computeTipVisibleBounds() {
// Compute area that the mouse can move in without hiding the
// tip window. Note that Java 1.4 can only detect mouse events
// in Java windows, not globally.
Rectangle r = tipWindow.getBounds();
Point p = r.getLocation();
SwingUtilities.convertPointFromScreen(p, textArea);
r.setLocation(p);
tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2);
}
示例10: updateClientCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void updateClientCursor() {
Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, this);
Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
if (target != null) {
content.setCursor(target.getCursor());
}
}
示例11: convertPointFromScreen
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public static void convertPointFromScreen(Object display, Point3f ptTemp) {
Point xyTemp = new Point();
xyTemp.x = (int) ptTemp.x;
xyTemp.y = (int) ptTemp.y;
SwingUtilities.convertPointFromScreen(xyTemp, (Component) display);
ptTemp.set(xyTemp.x, xyTemp.y, Float.NaN);
}
示例12: createPopup
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
void createPopup(int xpos, int ypos, boolean contextMenu) {
if (manager == null) {
return;
}
if (!popupAllowed) {
return;
}
if (!isShowing()) {
return;
}
JPopupMenu popup;
if (contextMenu) {
popup = Utilities.actionsToPopup(manager.getExploredContext().getActions(true), this);
} else {
Action[] actions = NodeOp.findActions(manager.getSelectedNodes());
popup = Utilities.actionsToPopup(actions, this);
}
if ((popup != null) && (popup.getSubElements().length > 0)) {
Point p = getViewport().getViewPosition();
p.x = xpos - p.x;
p.y = ypos - p.y;
SwingUtilities.convertPointToScreen(p, ListView.this);
Dimension popupSize = popup.getPreferredSize();
Rectangle screenBounds = Utilities.getUsableScreenBounds(getGraphicsConfiguration());
if ((p.x + popupSize.width) > (screenBounds.x + screenBounds.width)) {
p.x = (screenBounds.x + screenBounds.width) - popupSize.width;
}
if ((p.y + popupSize.height) > (screenBounds.y + screenBounds.height)) {
p.y = (screenBounds.y + screenBounds.height) - popupSize.height;
}
SwingUtilities.convertPointFromScreen(p, ListView.this);
popup.show(this, p.x, p.y);
}
}
示例13: isOnTop
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Finds out whether given pane container (window) is not under any other
* window registered in this manager at given screen point.
*
* @param rpc Pane container (window)
* @param screenLoc point relative to screen
* @return true when given window is on top of other registered windows at given point
*/
public boolean isOnTop (RootPaneContainer rpc, Point screenLoc) {
logger.entering(getClass().getName(), "isOnTop");
/*JComponent cp = (JComponent) rpc.getContentPane();
// false if point in dirty region - probably overlapped by other window
if (RepaintManager.currentManager(cp).getDirtyRegion(cp).contains(screenLoc)) {
return false;
}*/
int size = zOrder.size();
WeakReference<RootPaneContainer> curWeakW = null;
RootPaneContainer curRpc = null;
for (int i = size - 1; i >= 0; i--) {
curWeakW = zOrder.get(i);
if (curWeakW == null) {
continue;
}
curRpc = curWeakW.get();
// ignore excluded ones
if (getExcludedWeak(curRpc) != null) {
continue;
}
// return top one
if (curRpc == rpc) {
return true;
}
// safe cast, assured by checks in attachWindow method
Window curW = (Window) curRpc;
Point loc = new Point(screenLoc);
SwingUtilities.convertPointFromScreen(loc, curW);
if (curW.contains(loc)) {
// && !RepaintManager.currentManager(curComp).getDirtyRegion(curComp).contains(screenLoc)) {
return false;
}
}
// take main window automatically as last window to check
if (rpc == WindowManager.getDefault().getMainWindow()) {
return true;
}
// not found
return false;
}
示例14: isInToolbarPanel
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private boolean isInToolbarPanel( Point p ) {
Component c = ToolbarPool.getDefault();
SwingUtilities.convertPointFromScreen( p, c );
return c.contains( p );
}
示例15: showPopupAtMousePosition
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void showPopupAtMousePosition() {
// StaticDebug.debug("DND POPUP: Show popup at Mouse position");
// get mouse location
Point screenLocation = MouseInfo.getPointerInfo().getLocation();
screenLocation.x += 26;
screenLocation.y += 10;
// if tooltip is shown
if (tipWindow != null) {
// StaticDebug.debug("DND POPUP: Popup is already shown");
// check if mouse has moved
if (mouseX != screenLocation.x || mouseY != screenLocation.y) {
// StaticDebug.debug("DND POPUP: old position x = "+mouseX);
// StaticDebug.debug("DND POPUP: old position y = "+mouseY);
// StaticDebug.debug("DND POPUP: new position x = "+screenLocation.x);
// StaticDebug.debug("DND POPUP: new position y = "+screenLocation.y);
// StaticDebug.debug("DND POPUP: Mouse position has changed.. hide popup first");
// hide tooltip
hideDropDeniedTooltip();
} else {
// StaticDebug.debug("DND POPUP: Restart hide timer to prevent popup from being hidden.");
// otherwise restart hide timer
hideTimer.restart();
return;
}
}
Point componentLocation = (Point) screenLocation.clone();
SwingUtilities.convertPointFromScreen(componentLocation, popupSource);
if (tipWindow == null && popupSource.contains(componentLocation)) {
// StaticDebug.debug("DND POPUP: Mouse is inside popupSource and popup is not shown");
JToolTip tip = popupSource.createToolTip();
tip.setTipText(reason);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
mouseX = screenLocation.x;
mouseY = screenLocation.y;
// StaticDebug.debug("DND POPUP: show popup at "+mouseX+","+mouseY+" and start hide timer");
tipWindow = popupFactory.getPopup(popupSource, tip, mouseX, mouseY);
tipWindow.show();
hideTimer.restart();
}
}