本文整理汇总了Java中javax.swing.SwingUtilities.convertPointToScreen方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.convertPointToScreen方法的具体用法?Java SwingUtilities.convertPointToScreen怎么用?Java SwingUtilities.convertPointToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.convertPointToScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: right
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean right() {
Fix f = (Fix) getSelectedValue();
Iterable<? extends Fix> subfixes = HintsControllerImpl.getSubfixes(f);
if (subfixes.iterator().hasNext()) {
Rectangle r = getCellBounds(getSelectedIndex(), getSelectedIndex());
Point p = new Point(r.getLocation());
SwingUtilities.convertPointToScreen(p, this);
p.x += r.width;
// p.y += r.height;
HintsUI.getDefault().openSubList(subfixes, p);
return true;
}
return false;
}
示例2: press
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void press() throws AWTException {
Point point = this.table.getCellRect(1, 1, false).getLocation();
SwingUtilities.convertPointToScreen(point, this.table);
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.mouseMove(point.x + 1, point.y + 1);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
示例3: mouseDragged
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
Point newPos = e.getPoint();
SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
int xDelta = newPos.x - origPos.x;
int yDelta = newPos.y - origPos.y;
Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
if (wind!=null) { // Should always be true
if (getComponentOrientation().isLeftToRight()) {
int w = wind.getWidth();
if (newPos.x>=wind.getX()) {
w += xDelta;
}
int h = wind.getHeight();
if (newPos.y>=wind.getY()) {
h += yDelta;
}
wind.setSize(w,h);
}
else { // RTL
int newW = Math.max(1, wind.getWidth()-xDelta);
int newH = Math.max(1, wind.getHeight()+yDelta);
wind.setBounds(newPos.x, wind.getY(), newW, newH);
}
// invalidate()/validate() needed pre-1.6.
wind.invalidate();
wind.validate();
}
origPos.setLocation(newPos);
}
示例4: 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));
}
}
示例5: setVisible
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void setVisible(boolean visible) {
if (visible) {
if (size == null) {
size = getSize();
}
TopComponent editor = WindowManager.getDefault().getRegistry().getActivated();
Rectangle b = editor.getBounds();
Point location = new Point((b.x + (b.width / 2)) - (size.width / 2), (b.y + (b.height / 2)) - (size.height / 2));
SwingUtilities.convertPointToScreen(location, editor);
setLocation(location);
}
super.setVisible(visible);
}
示例6: pan
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private boolean pan (Widget widget, Point newLocation) {
if (scrollPane == null || scene != widget.getScene ())
return false;
newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation));
SwingUtilities.convertPointToScreen (newLocation, scene.getView ());
JComponent view = scene.getView ();
Rectangle rectangle = view.getVisibleRect ();
rectangle.x += lastLocation.x - newLocation.x;
rectangle.y += lastLocation.y - newLocation.y;
view.scrollRectToVisible (rectangle);
lastLocation = newLocation;
return true;
}
示例7: mouseReleased
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void mouseReleased(final MouseEvent me) {
if (!ourToolBarIsDragging)
return;
if ((me.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK) {
return;
}
hideDraggingWindow();
final Container target = ourDockLayout.getTargetContainer();
if (target == null)
return;
Point p = me.getPoint();
p = SwingUtilities.convertPoint(ourToolBar, p, target);
DockBoundary dock = null;
if (!me.isControlDown()) {
dock = getDockableBoundary(p);
if (dock != null) {
setDockIndex(dock.getDockIndex(p));
setRowIndex(dock.getRowIndex(p));
setDockEdge(dock.getEdge());
}
}
if (dock != null) {
dockToolBar(getDockEdge(), getRowIndex(), getDockIndex());
} else {
SwingUtilities.convertPointToScreen(p, target);
floatToolBar(p.x, p.y, true);
}
}
示例8: dragGestureRecognized
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
Point mousePosition = dge.getDragOrigin();
Point piecePosition = new Point(myStack.pos);
// Check drag starts inside piece
Rectangle r = myStack.stackConfigurer.getPieceBoundingBox();
r.translate(piecePosition.x, piecePosition.y);
if (!r.contains(mousePosition)) {
return;
}
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); // DEBUG
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}
示例9: resizePopup
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void resizePopup() {
popupWindow.pack();
Point point = new Point(0,0);
SwingUtilities.convertPointToScreen(point, getMainWindow());
popupWindow.setLocation( point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2,
point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3);
}
示例10: calcDrawOffset
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** calculates the offset between cursor dragCursor positions */
private void calcDrawOffset() {
if (drawWin != null) {
// drawOffset is the offset between the mouse location during a drag
// and the upper-left corner of the cursor
// accounts for difference between event point (screen coords)
// and Layered Pane position, boundingBox and off-center drag
drawOffset.x = -boundingBox.x - currentPieceOffsetX + EXTRA_BORDER;
drawOffset.y = -boundingBox.y - currentPieceOffsetY + EXTRA_BORDER;
SwingUtilities.convertPointToScreen(drawOffset, drawWin);
}
}
示例11: mouseClicked
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void mouseClicked(Map<String, List<OverrideDescription>> caption2Descriptions, JTextComponent c, Point p) {
if (caption2Descriptions.size() == 1 && caption2Descriptions.values().iterator().next().size() == 1) {
OverrideDescription desc = caption2Descriptions.values().iterator().next().get(0);
FileObject file = desc.location.getLocation().getFileObject();
if (file != null) {
UiUtils.open(file, desc.location.getLocation().getOffset());
} else {
Toolkit.getDefaultToolkit().beep();
}
return ;
}
Point position = new Point(p);
SwingUtilities.convertPointToScreen(position, c);
StringBuilder caption = new StringBuilder();
List<OverrideDescription> descriptions = new LinkedList<OverrideDescription>();
boolean first = true;
for (Entry<String, List<OverrideDescription>> e : caption2Descriptions.entrySet()) {
if (!first) {
caption.append("/");
}
first = false;
caption.append(e.getKey());
descriptions.addAll(e.getValue());
}
PopupUtil.showPopup(new IsOverriddenPopup(caption.toString(), descriptions), caption.toString(), position.x, position.y, true, 0);
}
示例12: resizePopup
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void resizePopup() {
popupWindow.pack();
Point point = new Point(0, 0);
SwingUtilities.convertPointToScreen(point, getMainWindow());
popupWindow.setLocation(point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2,
point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3);
}
示例13: guessSlideSide
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public String guessSlideSide (TopComponent comp) {
String toReturn = Constants.LEFT;
if (hierarchy.getMaximizedModeView() != null) {
//issue #58562
toReturn = (String)comp.getClientProperty("lastSlideSide");
if (toReturn == null) {
//TODO? now how does one figure on startup with maximazed mode where the editor is?
toReturn = Constants.LEFT;
}
} else {
Rectangle editorb = hierarchy.getPureEditorAreaBounds();
Point leftTop = new Point(0, 0);
SwingUtilities.convertPointToScreen(leftTop, comp);
if (editorb.x > leftTop.x) {
toReturn = Constants.LEFT;
comp.putClientProperty("lastSlideSide", toReturn);
}
if ((editorb.x + editorb.width) < leftTop.x) {
toReturn = Constants.RIGHT;
comp.putClientProperty("lastSlideSide", toReturn);
}
if ((editorb.y + editorb.height) < leftTop.y) {
toReturn = Constants.BOTTOM;
comp.putClientProperty("lastSlideSide", toReturn);
}
}
return toReturn;
}
示例14: showPanel
import javax.swing.SwingUtilities; //导入方法依赖的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 - 212) x = size.width - 212;
if (y > size.height - 167) y -= 165;
pop = PopupFactory.getSharedInstance().getPopup(owner, calendarPanel, x, y);
pop.show();
isShow = true;
}
示例15: dragGestureRecognized
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void dragGestureRecognized(DragGestureEvent dge) {
final Point mousePosition = dge.getDragOrigin();
dragStart = new Point(mousePosition);
final Region r = grid.getRegion(mousePosition);
if (r == null) {
return;
}
Point piecePosition = new Point(r.getOrigin());
originalPieceOffsetX = piecePosition.x - mousePosition.x;
originalPieceOffsetY = piecePosition.y - mousePosition.y;
drawWin = null;
makeDragCursor();
setDragCursor();
SwingUtilities.convertPointToScreen(drawOffset, drawWin);
SwingUtilities.convertPointToScreen(mousePosition, drawWin);
moveDragCursor(mousePosition.x, mousePosition.y);
// begin dragging
try {
dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
new StringSelection(""), this); //$NON-NLS-1$
dge.getDragSource().addDragSourceMotionListener(this);
}
catch (InvalidDnDOperationException e) {
ErrorDialog.bug(e);
}
}