本文整理了Java中javax.swing.JTree.convertValueToText()
方法的一些代码示例,展示了JTree.convertValueToText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.convertValueToText()
方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:convertValueToText
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-propertyeditors
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean isSelected, boolean expanded, boolean leaf, int row) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, false);
editorComponent = (JComponent)value;
container = tree;
return editorComponent;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-propertyeditors
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean isSelected, boolean expanded, boolean leaf, int row) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, false);
editorComponent = (JComponent)value;
container = tree;
return editorComponent;
}
代码示例来源:origin: org.fudaa.framework.ebli/ebli-3d
public String convertValueToText(final Object _value, final boolean _selected, final boolean _expanded,
final boolean _leaf, final int _row, final boolean _hasFocus) {
if (_value instanceof Objet3DInterface) {
return ((Objet3DInterface) _value).getName();
}
return super.convertValueToText(_value, _selected, _expanded, _leaf, _row, _hasFocus);
}
代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core
/** Implements the <code>TreeCellEditor</code> interface. */
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded,
boolean leaf, int row) {
String stringValue = tree.convertValueToText(value, isSelected, expanded, leaf, row, false);
delegate.setValue(stringValue);
return new JScrollPane(editorComponent);
}
代码示例来源:origin: com.synaptix/SynaptixSwing
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean isSelected, boolean expanded, boolean leaf, int row) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, false);
editorComponent.setValue(stringValue);
return editorComponent;
}
代码示例来源:origin: com.synaptix/SynaptixSwing
public Component getTreeCellEditorComponent(JTree tree, Object value,
boolean isSelected, boolean expanded, boolean leaf, int row) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, false);
editorComponent.setValue(stringValue);
return editorComponent;
}
代码示例来源:origin: stackoverflow.com
private static void getTreeText(JTree tree, TreeModel model, Object object, Collection<String> result) {
result.add(tree.convertValueToText(object, true, true, true, 0, true));
for (int i = 0; i < model.getChildCount(object); i++) {
getTreeText(tree, model, model.getChild(object, i), result);
}
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* Overrides this method to customize the styled label.
*
* @param tree
* @param value
* @param sel
* @param expanded
* @param leaf
* @param row
* @param hasFocus
*/
protected void customizeStyledLabel(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, sel,
expanded, leaf, row, hasFocus);
clearStyleRanges();
setText(stringValue);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
setEnabled(tree.isEnabled());
if (value instanceof CheckNode) {
CheckNode n = (CheckNode) value;
check.setSelected(n.isSelected());
label.setIcon(new ImageIcon(n.getIcon())); // XXX Ask description directly
}
if (isSelected) {
label.setForeground(LIST_FOR_COLORS.getSelectionForeground());
setOpaque(true);
setBackground(LIST_FOR_COLORS.getSelectionBackground());
} else {
label.setForeground(tree.getForeground());
setOpaque(false);
}
label.setText(stringValue);
return this;
}
}
代码示例来源:origin: joel-costigliola/assertj-swing
/**
* <p>
* Returns the internal value of a cell in a {@code JTree} as expected in a test.
* </p>
*
* <p>
* <b>Note:</b> This method is accessed in the current executing thread. Such thread may or may not be the event
* dispatch thread (EDT). Client code must call this method from the EDT.
* </p>
*
* @param tree the given {@code JTree}.
* @param modelValue the value of a cell, retrieved from the model.
* @return the internal value of a cell in a {@code JTree} as expected in a test.
*/
@Override
@RunsInCurrentThread
@Nullable public String valueAt(@Nonnull JTree tree, @Nullable Object modelValue) {
TreeCellRenderer r = tree.getCellRenderer();
Component c = r.getTreeCellRendererComponent(tree, modelValue, false, false, false, 0, false);
String value = (c != null) ? rendererReader.valueFrom(c) : null;
if (value != null) {
return value;
}
value = tree.convertValueToText(modelValue, false, false, false, 0, false);
if (isDefaultToString(value)) {
return null;
}
return value;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
setEnabled(tree.isEnabled());
if (value instanceof TypeNode) {
TypeNode n = (TypeNode) value;
stringValue = n.toStringAsHtml();
label.setIcon(new ImageIcon(n.getIcon()));
}
if (isSelected) {
label.setForeground(LIST_FOR_COLORS.getSelectionForeground());
setOpaque(true);
setBackground(LIST_FOR_COLORS.getSelectionBackground());
} else {
label.setForeground(tree.getForeground());
setOpaque(false);
}
label.setText(stringValue);
return this;
}
}
代码示例来源:origin: cytoscape.coreplugins/cpath2
/**
* Gets the Tree Cell Renderer.
* @param tree JTree Object.
* @param value Object value.
* @param isSelected Node is selected.
* @param expanded Node is expanded.
* @param leaf Node is a leaf.
* @param row Row number.
* @param hasFocus Node has focus.
* @return Custom Component.
*/
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
CustomNodePanel customNodePanel = new CustomNodePanel(tree, value,
expanded, leaf, stringValue);
customNodePanel.setEnabled(tree.isEnabled());
return customNodePanel;
}
}
代码示例来源:origin: org.cytoscape/cpath2-impl
/**
* Gets the Tree Cell Renderer.
* @param tree JTree Object.
* @param value Object value.
* @param isSelected Node is selected.
* @param expanded Node is expanded.
* @param leaf Node is a leaf.
* @param row Row number.
* @param hasFocus Node has focus.
* @return Custom Component.
*/
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
CustomNodePanel customNodePanel = new CustomNodePanel(tree, value,
expanded, leaf, stringValue);
customNodePanel.setEnabled(tree.isEnabled());
return customNodePanel;
}
}
代码示例来源:origin: sdedit/sdedit
/**
* Tries to find the next node that matches the text of the text field. If
* the text is not found, the search will wrap around, i. e. start at the
* root again. If the text is not found again then, this method will return
* <tt>null</tt>. Otherwise this method returns a path leading to a node
* that matches the text.
*
* @return
*/
public TreePath findNext() {
int state = 0;
TreePath next;
while (state < 2) {
while ((next = next()) != null) {
String str = currTree().convertValueToText(
next.getLastPathComponent(), false, false, false, 0,
false);
if (matches(str)) {
return next;
}
}
restart();
state++;
}
return null;
}
代码示例来源:origin: org.icepdf.os/icepdf-viewer
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
setEnabled(tree.isEnabled());
if (value instanceof LayersTreeNode) {
checkBox.setSelected(((LayersTreeNode) value).isSelected());
}
treeLabel.setFont(tree.getFont());
treeLabel.setText(stringValue);
treeLabel.setSelected(isSelected);
treeLabel.setFocus(hasFocus);
return this;
}
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, false);
checkBoxRenderer.setText(stringValue);
checkBoxRenderer.setSelected(false);
checkBoxRenderer.setEnabled(tree.isEnabled());
if (selected) {
checkBoxRenderer.setForeground(selectionForeground);
checkBoxRenderer.setBackground(selectionBackground);
} else {
checkBoxRenderer.setForeground(textForeground);
checkBoxRenderer.setBackground(textBackground);
}
if (value instanceof DefaultMutableTreeNode) {
Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
if (userObject instanceof SelectionModel) {
SelectionModel node = (SelectionModel) userObject;
checkBoxRenderer.setText(node.getText());
checkBoxRenderer.setSelected(node.isSelected());
checkBoxRenderer.setEnabled(node.isEnabled());
checkBoxRenderer.setIcon(node.getIcon());
return checkBoxRenderer;
}
}
return stdRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
}
代码示例来源:origin: google/sagetv
public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree,
Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean inHasFocus)
{
currValue = value;
String stringValue = (tree instanceof OracleTree) ?
((OracleTree) tree).convertValueToText(value, sel, expanded, leaf, row, hasFocus, true) :
tree.convertValueToText(value, sel, expanded, leaf, row, hasFocus);
hasFocus = inHasFocus;
setText(stringValue);
calculateSize();
if(sel)
{
setForeground(getTextSelectionColor());
}
else
{
setForeground(getTextNonSelectionColor());
}
setComponentOrientation(tree.getComponentOrientation());
selected = sel;
return this;
}
代码示例来源:origin: org.n52.wps/52n-wps-install-wizard
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
setEnabled(tree.isEnabled());
check.setSelected(((CheckNode)value).isSelected());
label.setFont(tree.getFont());
label.setText(stringValue);
label.setSelected(isSelected);
label.setFocus(hasFocus);
if (leaf) {
label.setIcon(UIManager.getIcon("Tree.leafIcon"));
} else if (expanded) {
label.setIcon(UIManager.getIcon("Tree.openIcon"));
} else {
label.setIcon(UIManager.getIcon("Tree.closedIcon"));
}
return this;
}
代码示例来源:origin: igniterealtime/Spark
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSelected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
String stringValue = tree.convertValueToText(value, isSelected,
expanded, leaf, row, hasFocus);
setEnabled(tree.isEnabled());
check.setSelected(((CheckNode)value).isSelected());
label.setFont(tree.getFont());
label.setText(stringValue);
label.setSelected(isSelected);
label.setFocus(hasFocus);
if (leaf) {
Icon icon = ((CheckNode)value).getIcon();
label.setIcon(icon);
}
else if (expanded) {
label.setIcon(UIManager.getIcon("Tree.openIcon"));
}
else {
label.setIcon(UIManager.getIcon("Tree.closedIcon"));
}
return this;
}
代码示例来源:origin: Jamling/SmartIM
/**
* 返回的是一个<code>JPanel</code>对象,该对象中包含一个<code>JCheckBox</code>对象 和一个
* <code>JLabel</code>对象。并且根据每个结点是否被选中来决定<code>JCheckBox</code> 是否被选中。
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
String stringValue = tree.convertValueToText(value, selected, expanded,
leaf, row, hasFocus);
setEnabled(tree.isEnabled());
if (value instanceof CheckBoxTreeNode) {
check.setSelected(((CheckBoxTreeNode) value).isSelected());
}
label.setFont(tree.getFont());
label.setText(stringValue);
label.setSelected(selected);
label.setFocus(hasFocus);
if (leaf)
label.setIcon(UIManager.getIcon("Tree.leafIcon"));
else if (expanded)
label.setIcon(UIManager.getIcon("Tree.openIcon"));
else
label.setIcon(UIManager.getIcon("Tree.closedIcon"));
return this;
}
内容来源于网络,如有侵权,请联系作者删除!