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


Java SwingUtilities.convertPoint方法代码示例

本文整理汇总了Java中javax.swing.SwingUtilities.convertPoint方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.convertPoint方法的具体用法?Java SwingUtilities.convertPoint怎么用?Java SwingUtilities.convertPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.SwingUtilities的用法示例。


在下文中一共展示了SwingUtilities.convertPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScrollDirection

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public int getScrollDirection(JScrollBarOperator oper) {
    Point toPoint = SwingUtilities.
            convertPoint(comp, x, y, getViewport().getView());
    int to = (orientation == JScrollBar.HORIZONTAL) ? toPoint.x : toPoint.y;
    int ln = (orientation == JScrollBar.HORIZONTAL) ? width : height;
    int lv = (orientation == JScrollBar.HORIZONTAL) ? getViewport().getWidth() : getViewport().getHeight();
    int vl = oper.getValue();
    if (to < vl) {
        return ScrollAdjuster.DECREASE_SCROLL_DIRECTION;
    } else if ((to + ln - 1) > (vl + lv)
            && to > vl) {
        return ScrollAdjuster.INCREASE_SCROLL_DIRECTION;
    } else {
        return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:JScrollPaneOperator.java

示例2: computePopupBounds

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
    Dimension cSize = comboBar.getSize();
    int width = getPopupWidth();
    Point location = new Point(cSize.width - width - 1, comboBar.getBottomLineY() - 1);
    if (SwingUtilities.getWindowAncestor(comboBar) != null) {
        location = SwingUtilities.convertPoint(comboBar, location, lPane);
    }
    result.setLocation(location);

    // hack to make jList.getpreferredSize work correctly
    // JList is listening on ResultsModel same as us and order of listeners
    // is undefined, so we have to force update of JList's layout data
    jList1.setFixedCellHeight(15);
    jList1.setFixedCellHeight(-1);
    // end of hack

    jList1.setVisibleRowCount(modelSize);
    Dimension preferredSize = jList1.getPreferredSize();

    preferredSize.width = width;
    preferredSize.height += statusPanel.getPreferredSize().height + 3;

    result.setSize(preferredSize);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:QuickSearchPopup.java

示例3: createPopup

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Find relevant actions and call the factory to create a popup.
 */
private JPopupMenu createPopup(Point p) {
    int[] selRows = table.getSelectedRows();
    Node[] arr = new Node[selRows.length];
    for (int i = 0; i < selRows.length; i++) {
        arr[i] = getNodeFromRow(selRows[i]);
    }
    if (arr.length == 0) {
        // hack to show something even when no rows are selected
        arr = new Node[] { manager.getRootContext() };
    }

    p = SwingUtilities.convertPoint(this, p, table);
    int column = table.columnAtPoint(p);
    int row = table.rowAtPoint(p);
    return popupFactory.createPopupMenu(row, column, arr, table);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TableView.java

示例4: showPopup

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
protected void showPopup (MouseEvent e) {
    int selRow = table.rowAtPoint(e.getPoint());

    if (selRow != -1) {
        if (! table.getSelectionModel().isSelectedIndex(selRow)) {
            table.getSelectionModel().clearSelection();
            table.getSelectionModel().setSelectionInterval(selRow, selRow);
        }
    } else {
        table.getSelectionModel().clearSelection();
    }
    Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TableView.this);
    if (isPopupAllowed()) {
        JPopupMenu pop = createPopup(p);
        TableView.this.showPopup(p.x, p.y, pop);
        e.consume();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TableView.java

示例5: getPositionForPopup

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Returns the point at which the popup menu is to be shown. May return null.
 * @return the point or null
 */    
private Point getPositionForPopup () {
    int i = outline.getSelectionModel().getLeadSelectionIndex();
    if (i < 0) return null;
    int j = outline.getColumnModel().getSelectionModel().getLeadSelectionIndex();
    if (j < 0) {
        j = 0;
    }

    Rectangle rect = outline.getCellRect(i, j, true);
    if (rect == null) return null;

    Point p = new Point(rect.x + rect.width / 3,
            rect.y + rect.height / 2);
    
    // bugfix #36984, convert point by TableView.this
    p =  SwingUtilities.convertPoint (outline, p, OutlineView.this);

    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:OutlineView.java

示例6: dropIndexOfPoint

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public int dropIndexOfPoint( Point location ) {
    int res = -1;
    location = SwingUtilities.convertPoint( this, location, table );
    TabData tab = table.getTabAt( location );
    if( null != tab ) {
        res = getModel().indexOf( tab );
        Rectangle rect = getTabBounds( res );
        rect = SwingUtilities.convertRectangle( this, rect, table );
        if( orientation == JTabbedPane.VERTICAL ) {
            if( location.y <= rect.y + rect.height/2 ) {
                res = Math.max( 0, res );
            } else {
                res++;
            }
        } else {
            if( location.x <= rect.x + rect.width/2 ) {
                res = Math.max( 0, res );
            } else {
                res++;
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SimpleTabDisplayer.java

示例7: onSwitcherTable

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Was mouse upon the popup table when mouse action had been taken.
 */
private boolean onSwitcherTable(MouseEvent e) {
    Point p = e.getPoint();
    //#118828
    if (! (e.getSource() instanceof Component)) {
        return false;
    }
    
    p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable);
    return pTable.contains(p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ButtonPopupSwitcher.java

示例8: start

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void start(MouseEvent e)
{
	initialAngle = mxUtils.getDouble(currentState.getStyle(),
			mxConstants.STYLE_ROTATION) * mxConstants.RAD_PER_DEG;
	currentAngle = initialAngle;
	first = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(),
			graphComponent.getGraphControl());

	if (!graphComponent.getGraph().isCellSelected(currentState.getCell()))
	{
		graphComponent.selectCellForEvent(currentState.getCell(), e);
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:17,代码来源:mxRotationHandler.java

示例9: showPopup

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void showPopup(MouseEvent mouseEvent) {
    if (isContextMenuOn()) {
        return;
    }
    Component component = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    if (component == null) {
        return;
    }
    if (component instanceof JMenuItem && (!(component instanceof JMenu) || ((JMenu) component).isSelected())) {
        return;
    }
    Point point = SwingUtilities.convertPoint(mouseEvent.getComponent(), mouseEvent.getPoint(), component);
    showPopup(component, point);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:ContextMenuHandler.java

示例10: mouseReleased

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
    Point p = SwingUtilities.convertPoint(this, e.getPoint(), bodyPanel);
    this.setForeground(Color.BLACK);
    lm.setSelect(p, false);
    commit();
}
 
开发者ID:sivanWu0222,项目名称:SimpleERP,代码行数:8,代码来源:Chooser.java

示例11: getDeepestComponentInPopups

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public JComponent getDeepestComponentInPopups(Point pt) {
    Component[] popups = menuEditLayer.layers.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
    for(Component popup : popups) {
        if(popup.isVisible()) {
            Point pt2 = SwingUtilities.convertPoint(menuEditLayer, pt, popup);
            JComponent child = (JComponent) javax.swing.SwingUtilities.getDeepestComponentAt(popup, pt2.x, pt2.y);
            if(child != null) return child;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DragOperation.java

示例12: convertPoint

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public Point convertPoint(Point pt)
{
	pt = SwingUtilities.convertPoint(graphComponent, pt,
			graphComponent.getGraphControl());

	pt.x -= graphComponent.getHorizontalScrollBar().getValue();
	pt.y -= graphComponent.getVerticalScrollBar().getValue();

	return pt;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:14,代码来源:mxGraphHandler.java

示例13: start

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void start(MouseEvent e) {
  initialAngle = mxUtils.getDouble(currentState.getStyle(), mxConstants.STYLE_ROTATION)
      * mxConstants.RAD_PER_DEG;
  currentAngle = initialAngle;
  first = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(),
      graphComponent.getGraphControl());

  if (!graphComponent.getGraph().isCellSelected(currentState.getCell())) {
    graphComponent.selectCellForEvent(currentState.getCell(), e);
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:mxRotationHandler.java

示例14: convertPoint

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Convert a <code>aPoint</code> in root component coordinate system to the
 * editor coordinate system. <code>aPoint</code> is assumed to be in the
 * root component coordinate system of the editor. If conversion is not
 * possible, return <code>aPoint</code> without any conversion.
 *
 * @param aPoint the Point to convert
 * @return aPoint converted to editor coordinate system
 */
public @NonNull Point convertPoint(Point aPoint) {
    Point value = aPoint;
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        value = SwingUtilities.convertPoint(pane.getRootPane(), value, pane);
    }
    return value;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:StickyWindowSupport.java

示例15: convertBoundsAndSetDropLine

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Converts line's bounds by the bounds of the root pane. Drop glass pane
 * is over this root pane. After covert a given line is set to drop glass pane.
 * @param line line for show in drop glass pane */
private void convertBoundsAndSetDropLine(final Line2D line) {
    int x1 = (int) line.getX1();
    int x2 = (int) line.getX2();
    int y1 = (int) line.getY1();
    int y2 = (int) line.getY2();
    Point p1 = SwingUtilities.convertPoint(tree, x1, y1, tree.getRootPane());
    Point p2 = SwingUtilities.convertPoint(tree, x2, y2, tree.getRootPane());
    line.setLine(p1, p2);
    if( null != dropPane )
        dropPane.setDropLine(line);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:TreeViewDropSupport.java


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