本文整理了Java中javax.swing.JTree.isRowSelected()
方法的一些代码示例,展示了JTree.isRowSelected()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.isRowSelected()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:isRowSelected
暂无
代码示例来源:origin: abbot/abbot
@Override
public Boolean call() throws Exception {
return tree.isRowSelected(targetRow);
}
})) {
代码示例来源:origin: net.sf.jt400/jt400
/**
Indicates if the object is selected.
@param object The object.
@return true if the object is selected; false otherwise.
**/
public boolean isSelected (VNode object)
{
if (object == null)
throw new NullPointerException ("object");
int row = findRow (object);
if (row > 0)
return tree_.isRowSelected (row);
else
return false;
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
protected void showPopup(MouseEvent e) {
int selRow = tree.getClosestRowForLocation(e.getX(), e.getY());
if (!tree.isRowSelected(selRow)) {
tree.setSelectionRow(selRow);
}
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
protected void showPopup (MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (!tree.isRowSelected(selRow)) {
tree.setSelectionRow(selRow);
}
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
protected void showPopup (MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (!tree.isRowSelected(selRow)) {
tree.setSelectionRow(selRow);
}
}
};
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
protected void showPopup (MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (!tree.isRowSelected(selRow)) {
// try {
// manager.setSelectedNodes(new Node[0]); // David's workaround
// } catch (PropertyVetoException exc) {
// ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc);
// }
// This will set ExplorerManager selection, no need to push
// it more (the commented out code above).
tree.setSelectionRow(selRow);
}
if (selRow != -1) {
Point p = SwingUtilities.convertPoint(e.getComponent(),e.getX(), e.getY(),TreeView.this);
createPopup((int)p.getX(), (int)p.getY());
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
protected void showPopup (MouseEvent e) {
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (!tree.isRowSelected(selRow)) {
// try {
// manager.setSelectedNodes(new Node[0]); // David's workaround
// } catch (PropertyVetoException exc) {
// ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc);
// }
// This will set ExplorerManager selection, no need to push
// it more (the commented out code above).
tree.setSelectionRow(selRow);
}
if (selRow != -1) {
Point p = SwingUtilities.convertPoint(e.getComponent(),e.getX(), e.getY(),TreeView.this);
createPopup((int)p.getX(), (int)p.getY());
}
}
}
代码示例来源:origin: tulskiy/musique
@Override
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
if (tree.isRowSelected(row)) {
Color bgColor;
bgColor = ((DefaultTreeCellRenderer) currentCellRenderer).getBackgroundSelectionColor();
g.setColor(bgColor);
g.fillRect(clipBounds.x, bounds.y, clipBounds.width, bounds.height);
}
super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
paintExpandControl(g, clipBounds, insets, bounds,
path, row, isExpanded,
hasBeenExpanded, isLeaf);
}
}
代码示例来源:origin: tulskiy/musique
@Override
protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
if (tree.isRowSelected(row)) {
Color bgColor;
bgColor = ((DefaultTreeCellRenderer) currentCellRenderer).getBackgroundSelectionColor();
g.setColor(bgColor);
g.fillRect(clipBounds.x, bounds.y, clipBounds.width, bounds.height);
}
super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
paintExpandControl(g, clipBounds, insets, bounds,
path, row, isExpanded,
hasBeenExpanded, isLeaf);
}
}
代码示例来源:origin: joel-costigliola/assertj-swing
@Override
protected Pair<Boolean, Point> executeInEDT() {
checkEnabledAndShowing(tree);
Point p = scrollToVisible(tree, row, location);
boolean selected = (!singleSelectRequired || tree.getSelectionCount() == 1) && tree.isRowSelected(row);
return Pair.of(selected, p);
}
});
代码示例来源:origin: org.biomoby/taverna-biomoby
public void paint(Graphics g) {
boolean selected = tree.isRowSelected(row);
Component renderer = tree
.getCellRenderer()
.getTreeCellRendererComponent(
tree,
path.getLastPathComponent(),
tree.isRowSelected(row),
tree.isExpanded(row),
tree.getModel().isLeaf(path.getLastPathComponent()),
row, selected);
c.setFont(tree.getFont());
Rectangle paintBounds = SwingUtilities.convertRectangle(tree,
bounds, this);
SwingUtilities.paintComponent(g, renderer, this, paintBounds);
if (selected)
return;
g.setColor(Color.blue);
((Graphics2D) g).draw(paintBounds);
}
};
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
protected void showPopup(MouseEvent e) {
tree.cancelEditing();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if ((selRow == -1) && !isRootVisible()) {
// clear selection
try {
manager.setSelectedNodes(new Node[]{});
} catch (PropertyVetoException exc) {
assert false : exc; // not permitted to be thrown
}
} else if (!tree.isRowSelected(selRow)) {
// This will set ExplorerManager selection as well.
// If selRow == -1 the selection will be cleared.
tree.setSelectionRow(selRow);
}
if ((selRow != -1) || !isRootVisible()) {
Point p = SwingUtilities.convertPoint(e.getComponent(), e.getX(), e.getY(), TreeView.this);
createPopup((int) p.getX(), (int) p.getY());
}
}
}
代码示例来源:origin: org.zaproxy/zap
/**
* @see #isButtonEnabledForNumberOfSelectedAlerts(int)
*/
@Override
public boolean isEnableForComponent(Component invoker) {
if(this.extAlert == null) {
return false;
}
if ("treeAlert".equals(invoker.getName())) {
setEnabled(!this.extAlert.getAlertPanel().getTreeAlert().isRowSelected(0) &&
isButtonEnabledForNumberOfSelectedAlerts(getNumberOfSelectedAlerts()));
return true;
}
return false;
}
代码示例来源:origin: info.aduna.commons/aduna-commons-swing
public void paint(Graphics g) {
boolean selected = tree.isRowSelected(row);
TreePath path = TreeOverlay.this.path;
if (path != null) {
JComponent renderer = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
path.getLastPathComponent(), tree.isRowSelected(row), tree.isExpanded(row),
tree.getModel().isLeaf(path.getLastPathComponent()), row, selected);
setFont(tree.getFont());
Rectangle paintBounds = SwingUtilities.convertRectangle(tree, bounds, this);
SwingUtilities.paintComponent(g, renderer, this, paintBounds);
int spacing = 0;
if (renderer instanceof JLabel) {
JLabel label = (JLabel) renderer;
if (label.getIcon() != null) {
spacing = label.getHorizontalTextPosition() + label.getIconTextGap();
}
}
g.setColor(Color.BLACK);
g.drawRect(paintBounds.x + spacing, paintBounds.y, paintBounds.width - spacing, paintBounds.height);
}
}
}
代码示例来源: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: nz.ac.waikato.cms.weka.thirdparty/bounce
protected void paintRow(Graphics g, Rectangle clipBounds,
Insets insets, Rectangle bounds, TreePath path,
int row, boolean isExpanded,
boolean hasBeenExpanded, boolean isLeaf) {
// Don't paint the renderer if editing this row.
if (editingComponent != null && editingRow == row) {
return;
}
Object object = path.getLastPathComponent();
Component component = currentCellRenderer.getTreeCellRendererComponent(tree,
object, tree.isRowSelected(row),
isExpanded, isLeaf, row, false); // hasfocus???
// don't indent the end-tag as far...
if ( object instanceof ElementEndTreeNode) {
int indent = getLeftChildIndent() + getRightChildIndent();
rendererPane.paintComponent(g, component, tree, bounds.x-indent, bounds.y, bounds.width, bounds.height, true);
} else {
rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y, bounds.width, bounds.height, true);
}
}
代码示例来源: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: de.sciss/jtreetable
protected void paintTable(Graphics g) {
treeTableCellRenderer.prepareForTable(g);
Graphics cg = g.create(0, 0, treeTable.getWidth(), treeTable.getHeight());
try {
table.paint(cg);
} finally {
cg.dispose();
}
// JTable doesn't paint anything for the editing cell,
// so painting the background color is placed here
if (table.isEditing()) {
int col = table.getEditingColumn();
int row = table.getEditingRow();
boolean sel = treeTableCellRenderer.isSelected(
tree.isRowSelected(row) && table.isColumnSelected(col));
TreeTableCellRenderer r = treeTable.getCellRenderer(row, col);
Component c = r.getTreeTableCellRendererComponent(
treeTable, null, sel, false, row, col);
// TODO, create CellRendererPane for TreeTable, for use by the focus renderer too.
CellRendererPane rp = (CellRendererPane)table.getComponent(0);
Rectangle cell = table.getCellRect(row, col, true);
rp.paintComponent(g, c, table, cell.x, cell.y, cell.width, cell.height, true);
rp.removeAll();
}
}
代码示例来源:origin: com.github.insubstantial/substance
/**
* Returns the current state for the specified path.
*
* @param pathId
* Path index.
* @return The current state for the specified path.
*/
public ComponentState getPathState(TreePathId pathId) {
boolean isEnabled = this.tree.isEnabled();
StateTransitionTracker tracker = this.stateTransitionMultiTracker
.getTracker(pathId);
if (tracker == null) {
int rowIndex = this.tree.getRowForPath(pathId.path);
boolean isRollover = (this.currRolloverPathId != null)
&& pathId.equals(this.currRolloverPathId);
boolean isSelected = this.tree.isRowSelected(rowIndex);
return ComponentState.getState(isEnabled, isRollover, isSelected);
} else {
ComponentState fromTracker = tracker.getModelStateInfo()
.getCurrModelState();
return ComponentState.getState(isEnabled, fromTracker
.isFacetActive(ComponentStateFacet.ROLLOVER), fromTracker
.isFacetActive(ComponentStateFacet.SELECTION));
}
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Returns the current state for the specified path.
*
* @param pathId
* Path index.
* @return The current state for the specified path.
*/
public ComponentState getPathState(TreePathId pathId) {
boolean isEnabled = this.tree.isEnabled();
StateTransitionTracker tracker = this.stateTransitionMultiTracker
.getTracker(pathId);
if (tracker == null) {
int rowIndex = this.tree.getRowForPath(pathId.path);
boolean isRollover = (this.currRolloverPathId != null)
&& pathId.equals(this.currRolloverPathId);
boolean isSelected = this.tree.isRowSelected(rowIndex);
return ComponentState.getState(isEnabled, isRollover, isSelected);
} else {
ComponentState fromTracker = tracker.getModelStateInfo()
.getCurrModelState();
return ComponentState.getState(isEnabled, fromTracker
.isFacetActive(ComponentStateFacet.ROLLOVER), fromTracker
.isFacetActive(ComponentStateFacet.SELECTION));
}
}
内容来源于网络,如有侵权,请联系作者删除!