本文整理了Java中javax.swing.JTree.hasFocus()
方法的一些代码示例,展示了JTree.hasFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.hasFocus()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:hasFocus
暂无
代码示例来源:origin: mucommander/mucommander
@Override
public Color getBackgroundSelectionColor() {
if (tree!=null && tree.hasFocus()) {
return ThemeCache.backgroundColors[ThemeCache.ACTIVE][ThemeCache.SELECTED];
} else {
return ThemeCache.backgroundColors[ThemeCache.INACTIVE][ThemeCache.SELECTED];
}
}
代码示例来源:origin: mucommander/mucommander
@Override
public Color getBackgroundNonSelectionColor() {
if (tree!=null && tree.hasFocus()) {
return ThemeCache.backgroundColors[ThemeCache.ACTIVE][ThemeCache.NORMAL];
} else {
return ThemeCache.backgroundColors[ThemeCache.INACTIVE][ThemeCache.NORMAL];
}
}
代码示例来源:origin: mucommander/mucommander
@Override
public Color getForeground() {
if (tree!=null && tree.hasFocus()) {
return selected ? ThemeCache.foregroundColors[ThemeCache.ACTIVE][ThemeCache.SELECTED][ThemeCache.FOLDER] :
ThemeCache.foregroundColors[ThemeCache.ACTIVE][ThemeCache.NORMAL][ThemeCache.FOLDER];
} else {
return selected ? ThemeCache.foregroundColors[ThemeCache.INACTIVE][ThemeCache.SELECTED][ThemeCache.FOLDER] :
ThemeCache.foregroundColors[ThemeCache.INACTIVE][ThemeCache.NORMAL][ThemeCache.FOLDER];
}
}
代码示例来源:origin: mucommander/mucommander
public void colorChanged(ColorChangedEvent event) {
if (tree.hasFocus()) {
tree.setBackground(ThemeCache.backgroundColors[ThemeCache.ACTIVE][ThemeCache.NORMAL]);
} else {
tree.setBackground(ThemeCache.backgroundColors[ThemeCache.INACTIVE][ThemeCache.NORMAL]);
}
tree.repaint();
}
代码示例来源:origin: com.jidesoft/jide-oss
public void mousePressed(MouseEvent e) {
if (e.isConsumed()) {
return;
}
TreePath path = preventToggleEvent(e);
if (path != null) {
toggleSelections(new TreePath[]{path});
Object source = e.getSource();
if (source instanceof JTree) {
JTree tree = ((JTree) source);
if (!tree.hasFocus() && tree.isFocusable() && tree.isRequestFocusEnabled()) {
tree.requestFocusInWindow();
}
}
e.consume();
}
}
代码示例来源: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: UNIVALI-LITE/Portugol-Studio
@Override
public void paint(Graphics g, JComponent c) {
JTree tree = (JTree) c;
if(tree.isOpaque()){
g.setColor(tree.getBackground());
g.fillRect(0, 0, tree.getWidth(), tree.getHeight());
}
if (tree.getSelectionCount() > 0) {
g.setColor(ColorController.COR_DESTAQUE);
//@see http://ateraimemo.com/Swing/TreeRowSelection.html
for (int i : tree.getSelectionRows()) {
Rectangle r = tree.getRowBounds(i);
g.fillRect(0, r.y, tree.getWidth(), r.height);
}
}
super.paint(g, c);
if (tree.getLeadSelectionPath() != null) {
Rectangle r = tree.getRowBounds(getRowForPath(tree, tree.getLeadSelectionPath()));
g.setColor(tree.hasFocus() ? ColorController.FUNDO_MEDIO.brighter(): ColorController.FUNDO_MEDIO);
// g.drawRect(0, r.y, tree.getWidth() - 1, r.height - 1);
}
}
代码示例来源:origin: com.jidesoft/jide-oss
return tree.convertValueToText(treeNode, selected, tree.isExpanded((TreePath) object), tree.getModel().isLeaf(treeNode), tree.getRowForPath((TreePath) object), tree.hasFocus() && tree.getLeadSelectionPath() == object);
代码示例来源: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: org.gosu-lang.gosu/gosu-editor
if( _bSelected && _tree.hasFocus() )
if( _bSelected && _tree.hasFocus() )
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
if( _bSelected && _tree.hasFocus() )
if( _bSelected && _tree.hasFocus() )
代码示例来源:origin: com.github.insubstantial/substance
.getLastPathComponent(), this.tree
.isRowSelected(row), isExpanded, isLeaf,
row, tree.hasFocus() ? (tree
.getLeadSelectionRow() == row)
: false);
代码示例来源:origin: org.java.net.substance/substance
.getLastPathComponent(), this.tree
.isRowSelected(row), isExpanded, isLeaf,
row, tree.hasFocus() ? (tree
.getLeadSelectionRow() == row)
: false);
代码示例来源:origin: org.java.net.substance/substance
if (this.tree.hasFocus()) {
TreePath leadPath = this.tree.getLeadSelectionPath();
leadIndex = this.getRowForPath(this.tree, leadPath);
代码示例来源:origin: com.github.insubstantial/substance
if (this.tree.hasFocus()) {
TreePath leadPath = this.tree.getLeadSelectionPath();
leadIndex = this.getRowForPath(this.tree, leadPath);
代码示例来源:origin: khuxtable/seaglass
if (tree.hasFocus()) {
leadIndex = getLeadSelectionRow();
} else {
内容来源于网络,如有侵权,请联系作者删除!