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