本文整理匯總了Java中javax.swing.JTree.setBackground方法的典型用法代碼示例。如果您正苦於以下問題:Java JTree.setBackground方法的具體用法?Java JTree.setBackground怎麽用?Java JTree.setBackground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.setBackground方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: editLaF
import javax.swing.JTree; //導入方法依賴的package包/類
public final void editLaF(JTree tree) {
UIDefaults paneDefaults = new UIDefaults();
paneDefaults.put("Tree.selectionBackground", null);
tree.putClientProperty("Nimbus.Overrides", paneDefaults);
tree.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
tree.setBackground(Color.WHITE);
}
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:8,代碼來源:TreeSelectionRenderer.java
示例2: initializeTree
import javax.swing.JTree; //導入方法依賴的package包/類
private void initializeTree() {
tree = new JTree();
tree.setCellRenderer(new CustomTreeRenderer());
tree.setVisibleRowCount(8);
tree.setBackground(background);
tree.addTreeSelectionListener(this);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(true);
}
示例3: createDocPane
import javax.swing.JTree; //導入方法依賴的package包/類
private JTree createDocPane() {
final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
.entrySet()) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
root.add(node);
for (Object rule : docEntry.getValue()) {
node.add(new DefaultMutableTreeNode(rule));
}
}
final JTree result = new JTree(root) {
@Override
public String getToolTipText(MouseEvent evt) {
if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
return null;
}
TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
Object userObject =
((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
return getToolTip(userObject);
}
};
result.setRootVisible(false);
result.setShowsRootHandles(true);
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
renderer.setBackgroundNonSelectionColor(null);
renderer.setBackgroundSelectionColor(null);
renderer.setTextSelectionColor(null);
renderer.setLeafIcon(null);
renderer.setClosedIcon(null);
renderer.setOpenIcon(null);
result.setCellRenderer(renderer);
ToolTipManager.sharedInstance()
.registerComponent(result);
result.addMouseListener(new DismissDelayer(result));
for (int i = 0; i < root.getChildCount(); i++) {
result
.expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
}
result.setBackground(null);
return result;
}