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

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

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

JTree.getLeadSelectionRow介绍

暂无

代码示例

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

static void scrollTreeToSelectedRow(final JTree tree) {
  final int selectedRow = tree.getLeadSelectionRow();
  if (selectedRow >=0) {
    SwingUtilities.invokeLater(
        new Runnable() {
      public void run() {
        tree.scrollRectToVisible(tree.getRowBounds(selectedRow));
      }
    }
    );
  }
}

代码示例来源: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: 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: stackoverflow.com

System.out.println("Min: " + treeSource.getMinSelectionRow());
System.out.println("Max: " + treeSource.getMaxSelectionRow());
System.out.println("Lead: " + treeSource.getLeadSelectionRow());
System.out.println("Row: " + treeSource.getSelectionRows()[0]);

代码示例来源:origin: stackoverflow.com

System.out.println("Min: " + treeSource.getMinSelectionRow());
System.out.println("Max: " + treeSource.getMaxSelectionRow());
System.out.println("Lead: " + treeSource.getLeadSelectionRow());
System.out.println("Row: " + treeSource.getSelectionRows()[0]);

代码示例来源:origin: stackoverflow.com

System.out.println("Min: " + treeSource.getMinSelectionRow());
System.out.println("Max: " + treeSource.getMaxSelectionRow());
System.out.println("Lead: " + treeSource.getLeadSelectionRow());
System.out.println("Row: " + treeSource.getSelectionRows()[0]);

代码示例来源:origin: org.gephi/directory-chooser

int selRow = tree.getLeadSelectionRow();
if (selRow >= 0) {
  Rectangle bounds = tree.getRowBounds(selRow);

代码示例来源:origin: robotframework/SwingLibrary

private Component getNodeComponent(Object node, TreePath treePath) {
  int row = tree.getRowForPath(treePath);
  boolean isLeaf = tree.getModel().isLeaf(node);
  boolean hasFocus = tree.getLeadSelectionRow() == row;
  boolean isSelected = tree.isRowSelected(row);
  boolean isExpanded = tree.isExpanded(row);
  TreeCellRenderer cellRenderer = tree.getCellRenderer();
  return cellRenderer.getTreeCellRendererComponent(tree, node, isSelected, isExpanded, isLeaf, row, hasFocus);
}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

public Component getRendererComponent() {
  TreeModel treeModel = tree.getModel();
  TreePath treePath = tree.getPathForRow(rowIndex);
  TreeCellRenderer renderer = tree.getCellRenderer();
  boolean isSelected = tree.isPathSelected(treePath);
  boolean isExpanded = tree.isExpanded(treePath);
  boolean hasFocus = tree.hasFocus() && rowIndex == tree.getLeadSelectionRow();
  Object item = treePath.getLastPathComponent();
  boolean isLeaf = treeModel.isLeaf(item);
  Component component = renderer.getTreeCellRendererComponent(tree, item, isSelected, isExpanded, isLeaf, rowIndex, hasFocus);
  component.setFont(tree.getFont());
  // FIX Nimbus white foreground on white background
  if (isSelected) {
    component.setForeground(UIManager.getColor("Tree.textForeground"));
  }
  return component;
}

代码示例来源:origin: org.nuiton/nuiton-widgets

public Component getRendererComponent() {
  TreeModel treeModel = tree.getModel();
  TreePath treePath = tree.getPathForRow(rowIndex);
  TreeCellRenderer renderer = tree.getCellRenderer();
  boolean isSelected = tree.isPathSelected(treePath);
  boolean isExpanded = tree.isExpanded(treePath);
  boolean hasFocus = tree.hasFocus() && rowIndex == tree.getLeadSelectionRow();
  Object item = treePath.getLastPathComponent();
  boolean isLeaf = treeModel.isLeaf(item);
  Component component = renderer.getTreeCellRendererComponent(tree, item, isSelected, isExpanded, isLeaf, rowIndex, hasFocus);
  component.setFont(tree.getFont());
  
  // FIX Nimbus white foreground on white background
  if (isSelected) {
    component.setForeground(UIManager.getColor("Tree.textForeground"));
  }
  return component;
}

代码示例来源:origin: javax.help/javahelp

private static Component getComponentAt(JTree tree, int x, int y) {
  try {
    
    TreePath path = tree.getPathForLocation(x, y);
    
    if (tree.isEditing() && tree.getSelectionPath() == path) {
      return null;
    }
    
    int row = tree.getRowForPath(path);
    Object value = path.getLastPathComponent();
    boolean isSelected = tree.isRowSelected(row);
    boolean isExpanded = tree.isExpanded(path);
    boolean isLeaf = tree.getModel().isLeaf(value);
    boolean hasFocus= tree.hasFocus() && tree.getLeadSelectionRow() == row;
    
    return tree.getCellRenderer().getTreeCellRendererComponent(
    tree, value, isSelected, isExpanded, isLeaf, row, hasFocus);
    
  } catch (Exception e) {
    return null;
  }
}

代码示例来源:origin: com.github.insubstantial/substance

.isRowSelected(row), isExpanded, isLeaf,
        row, tree.hasFocus() ? (tree
            .getLeadSelectionRow() == row)
            : false);
Color background = renderer.getBackground();

代码示例来源:origin: org.java.net.substance/substance

.isRowSelected(row), isExpanded, isLeaf,
        row, tree.hasFocus() ? (tree
            .getLeadSelectionRow() == row)
            : false);
Color background = renderer.getBackground();

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

public void prepareForTable(Graphics g) {
  prepareBackgroundColors();
  int cm = treeTable.getColumnModel().getColumnMargin();
  int rm = treeTable.getRowMargin();
  if (cm != 0 || rm != 0) {
    left = cm/2;
    right = left + cm%2;
    top = rm/2;
    bottom = top + rm%2;
  } else {
    left = right = top = bottom = 0;
  }
  if (treeTable.getFocusRenderer() != null) {
    focusRow = focusColumn = -1;
  } else {
    focusRow = tree.getLeadSelectionRow();
    if (treeTable.isColumnFocusEnabled()) {
      focusColumn = Integer.MIN_VALUE;
    } else {
      focusColumn = treeTable.getLeadSelectionColumn();
    }
  }
}

相关文章

JTree类方法