本文整理汇总了Java中org.jdesktop.swingx.JXTree.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JXTree.setForeground方法的具体用法?Java JXTree.setForeground怎么用?Java JXTree.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.JXTree
的用法示例。
在下文中一共展示了JXTree.setForeground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interactiveTransparentRenderer
import org.jdesktop.swingx.JXTree; //导入方法依赖的package包/类
public void interactiveTransparentRenderer() throws IOException {
final JXTree tree = new JXTree(new ComponentTreeTableModel(new JXFrame()));
tree.setEditable(true);
StringValue sv = new StringValue() {
public String getString(Object value) {
if (value instanceof Component) {
return ((Component) value).getName();
}
return " - no component - ";
}};
DefaultTreeRenderer renderer = new DefaultTreeRenderer(sv);
tree.setCellRenderer(renderer);
tree.setForeground(Color.WHITE);
JXPanel panel = new JXPanel(new BorderLayout());
ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage());
imagePainter.setFillHorizontal(true);
imagePainter.setFillVertical(true);
panel.setBackgroundPainter(imagePainter);
panel.add(new JScrollPane(tree));
JXFrame frame = wrapInFrame(panel, "renderer");
WrappingProvider provider = (WrappingProvider) renderer.getComponentProvider();
provider.getWrappee().getRendererComponent(null).setOpaque(false);
tree.setOpaque(false);
((JComponent) tree.getParent()).setOpaque(false);
((JComponent) tree.getParent().getParent()).setOpaque(false);
Action edit = new AbstractActionExt("edit") {
public void actionPerformed(ActionEvent e) {
if (tree.isSelectionEmpty()) return;
TreePath path = tree.getSelectionPath();
Component comp = (Component) path.getLastPathComponent();
String oldName = comp.getName();
if (oldName == null) {
oldName = "none";
}
String changed = oldName.length() > 60 ? oldName.substring(0, 20) :
oldName + "+++++++++++++++++++++++++++++++++++++++++++++";
tree.getModel().valueForPathChanged(path, changed);
}
};
addAction(frame, edit);
show(frame);
}