javax.swing.JTree.getRowBounds()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中javax.swing.JTree.getRowBounds()方法的一些代码示例,展示了JTree.getRowBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getRowBounds()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getRowBounds

JTree.getRowBounds介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

public boolean inCheckBoxHitRegion(MouseEvent e) {
 TreePath path = tree.getPathForLocation(e.getX(),
   e.getY());
 if (path == null) {
  return false;
 }
 CategoryNode node = (CategoryNode) path.getLastPathComponent();
 boolean rv = false;
 if (true) {
  // offset and lastRow DefaultTreeCellEditor
  // protected members
  Rectangle bounds = tree.getRowBounds(lastRow);
  Dimension checkBoxOffset =
    renderer.getCheckBoxOffset();
  bounds.translate(offset + checkBoxOffset.width,
    checkBoxOffset.height);
  rv = bounds.contains(e.getPoint());
 }
 return true;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public boolean inCheckBoxHitRegion(MouseEvent e) {
 TreePath path = tree.getPathForLocation(e.getX(),
   e.getY());
 if (path == null) {
  return false;
 }
 CategoryNode node = (CategoryNode) path.getLastPathComponent();
 boolean rv = false;
 if (true) {
  // offset and lastRow DefaultTreeCellEditor
  // protected members
  Rectangle bounds = tree.getRowBounds(lastRow);
  Dimension checkBoxOffset =
    renderer.getCheckBoxOffset();
  bounds.translate(offset + checkBoxOffset.width,
    checkBoxOffset.height);
  rv = bounds.contains(e.getPoint());
 }
 return true;
}

代码示例来源:origin: abbot/abbot

@Override
  public Rectangle call() {
    return tree.getRowBounds(row);
  }
});

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
public Rectangle getRowBounds(int row) {
  Rectangle r = super.getRowBounds(row);
  if (r == null) {
    LOG.log(Level.WARNING, "No bounds for row {0} in three view: {1}", new Object[]{row, this});
    return new Rectangle();
  }
  return r;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

public void run() {
    tree.scrollRectToVisible(tree.getRowBounds(selectedRow));
  }
}

代码示例来源:origin: UISpec4J/UISpec4J

private Rectangle getRectangle(TreePath treePath) {
 return jTree.getRowBounds(jTree.getRowForPath(treePath));
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@Override
protected void updateRolloverPoint(JComponent component, Point mousePoint) {
  JTree tree = (JTree) component;
  int row = tree.getClosestRowForLocation(mousePoint.x, mousePoint.y);
  Rectangle bounds = tree.getRowBounds(row);
  if (bounds == null) {
    row = -1;
  } else {
    if ((bounds.y + bounds.height < mousePoint.y)
        || bounds.x > mousePoint.x) {
      row = -1;
    }
  }
  int col = row < 0 ? -1 : 0;
  rollover.x = col;
  rollover.y = row;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
protected void updateRolloverPoint(JComponent component, Point mousePoint) {
  JTree tree = (JTree) component;
  int row = tree.getClosestRowForLocation(mousePoint.x, mousePoint.y);
  Rectangle bounds = tree.getRowBounds(row);
  if (bounds == null) {
    row = -1;
  } else {
    if ((bounds.y + bounds.height < mousePoint.y)
        || bounds.x > mousePoint.x) {
      row = -1;
    }
  }
  int col = row < 0 ? -1 : 0;
  rollover.x = col;
  rollover.y = row;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
protected void updateRolloverPoint(JComponent component, Point mousePoint) {
  JTree tree = (JTree) component;
  int row = tree.getClosestRowForLocation(mousePoint.x, mousePoint.y);
  Rectangle bounds = tree.getRowBounds(row);
  if (bounds == null) {
    row = -1;
  } else {
    if ((bounds.y + bounds.height < mousePoint.y)
        || bounds.x > mousePoint.x) {
      row = -1;
    }
  }
  int col = row < 0 ? -1 : 0;
  rollover.x = col;
  rollover.y = row;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@Override
protected void updateRolloverPoint(JComponent component, Point mousePoint) {
  JTree tree = (JTree) component;
  int row = tree.getClosestRowForLocation(mousePoint.x, mousePoint.y);
  Rectangle bounds = tree.getRowBounds(row);
  if (bounds == null) {
    row = -1;
  } else {
    if ((bounds.y + bounds.height < mousePoint.y)
        || bounds.x > mousePoint.x) {
      row = -1;
    }
  }
  int col = row < 0 ? -1 : 0;
  rollover.x = col;
  rollover.y = row;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Returns the the point at which the popup menu is to be showed. May return null.
 * @return the point or null
 */    
Point getPositionForPopup () {
  int i = tree.getLeadSelectionRow();
  if (i < 0) return null;
  Rectangle rect = tree.getRowBounds(i);
  if (rect == null) return null;
  Point p = new Point (rect.x, rect.y);
  
  // bugfix #36984, convert point by TreeView.this
  p =  SwingUtilities.convertPoint (tree, p, TreeView.this);
  return p;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Returns the the point at which the popup menu is to be showed. May return null.
 * @return the point or null
 */    
Point getPositionForPopup () {
  int i = tree.getLeadSelectionRow();
  if (i < 0) return null;
  Rectangle rect = tree.getRowBounds(i);
  if (rect == null) return null;
  Point p = new Point (rect.x, rect.y);
  
  // bugfix #36984, convert point by TreeView.this
  p =  SwingUtilities.convertPoint (tree, p, TreeView.this);
  return p;
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/** Returns the the point at which the popup menu is to be showed. May return null.
 * @return the point or null
 */
Point getPositionForPopup() {
  int i = tree.getLeadSelectionRow();
  if (i < 0) {
    return null;
  }
  Rectangle rect = tree.getRowBounds(i);
  if (rect == null) {
    return null;
  }
  Point p = new Point(rect.x, rect.y);
  // bugfix #36984, convert point by TreeView.this
  p = SwingUtilities.convertPoint(tree, p, TreeView.this);
  return p;
}

代码示例来源:origin: de.sciss/jtreetable

public void setBounds(int x, int y, int w, int h) {
  Rectangle node = tree.getRowBounds(row);
  if (tree.getComponentOrientation().isLeftToRight()) {
    x = node.x;
    w -= node.x;
  } else {
    w = node.x + node.width;
  }
  component.setBounds(0, 0, w, h);
  super.setBounds(x, y, w, h);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

Point getPositionForPopup() {
  int row = treeTable.getSelectedRow();
  if ( row < 0 )
    return null;
  int col = treeTable.getSelectedColumn();
  if ( col < 0 )
    col = 0;
  
  Rectangle r = null;
  if ( col == 0 )
    r = tree.getRowBounds( row );
  else
    r = treeTable.getCellRect( row, col, true );
  Point p = SwingUtilities.convertPoint( treeTable, r.x, r.y, this);
  
  return p;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

Point getPositionForPopup() {
  int row = treeTable.getSelectedRow();
  if ( row < 0 )
    return null;
  int col = treeTable.getSelectedColumn();
  if ( col < 0 )
    col = 0;
  
  Rectangle r = null;
  if ( col == 0 )
    r = tree.getRowBounds( row );
  else
    r = treeTable.getCellRect( row, col, true );
  Point p = SwingUtilities.convertPoint( treeTable, r.x, r.y, this);
  
  return p;
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
Point getPositionForPopup() {
  int row = treeTable.getSelectedRow();
  if (row < 0) {
    return null;
  }
  int col = treeTable.getSelectedColumn();
  if (col < 0) {
    col = 0;
  }
  Rectangle r;
  if (col == 0) {
    r = tree.getRowBounds(row);
  } else {
    r = treeTable.getCellRect(row, col, true);
  }
  Point p = SwingUtilities.convertPoint(treeTable, r.x, r.y, this);
  return p;
}

代码示例来源:origin: abbot/abbot

public Rectangle call() {
    int row = tree.getRowForLocation(where.x, where.y);
    if (tree.getLeadSelectionRow() != row
      || tree.getSelectionCount() != 1) {
      // NOTE: the row bounds *do not* include the expansion handle
      return tree.getRowBounds(row);
    }
    else {
      return null;
    }
  }
});

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
                         boolean leaf, int row, boolean hasFocus) {
    componentBeingRendered = tree;
    Rectangle cellBounds = new Rectangle();
    if (!gettingCellBounds) {
      gettingCellBounds = true;
      cellBounds = tree.getRowBounds(row);
      gettingCellBounds = false;
    }
    setupLinkedObjectComponent(tree, cellBounds);
    preferredWidth = -1;
    minTextHeight = 12;
//        textPane.setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 2 + rightMargin));
    tree.setToolTipText(value != null ? value.toString() : "");
    Component c = prepareRenderer(value, selected, hasFocus);
    reset();
    return c;
  }

代码示例来源:origin: de.sciss/jtreetable

public boolean editCellAt(int row, int col, EventObject e) {
      if (super.editCellAt(row, col, e)) {
        if (col == treeTable.getHierarchicalColumn()) {
          Rectangle b = tree.getRowBounds(row);
          b.x = 0;
          b.width = tree.getWidth();
          tree.repaint(b);
        }
        return true;
      }
      return false;
//            return super.editCellAt(row, col, e);
    }

相关文章

JTree类方法