public static TreeNode getRoot() {
DefaultMutableTreeNode node = new DefaultMutableTreeNode("root");
DefaultMutableTreeNode first = new DefaultMutableTreeNode("first");
DefaultMutableTreeNode second = new DefaultMutableTreeNode("second");
DefaultMutableTreeNode third = new DefaultMutableTreeNode("third");
first.add(new DefaultMutableTreeNode("1.1"));
first.add(new DefaultMutableTreeNode("1.2"));
first.add(new DefaultMutableTreeNode("1.3"));
second.add(new DefaultMutableTreeNode("2.1"));
second.add(new DefaultMutableTreeNode("2.2"));
second.add(new DefaultMutableTreeNode("2.3"));
third.add(new DefaultMutableTreeNode("3.1"));
third.add(new DefaultMutableTreeNode("3.2"));
third.add(new DefaultMutableTreeNode("3.3"));
node.add(first);
node.add(second);
node.add(third);
return node;
}
java类javax.swing.tree.DefaultMutableTreeNode的实例源码
Test4631471.java 文件源码
项目:jdk8u-jdk
阅读 42
收藏 0
点赞 0
评论 0
Test8015926.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void run() {
Thread.currentThread().setUncaughtExceptionHandler(this);
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
DefaultMutableTreeNode child = new DefaultMutableTreeNode("Child");
DefaultTreeModel model = new DefaultTreeModel(root);
this.tree = new JTree();
this.tree.setModel(model);
JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(this.tree);
model.addTreeModelListener(this); // frame is not visible yet
model.insertNodeInto(child, root, root.getChildCount());
model.removeNodeFromParent(child);
frame.setSize(640, 480);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
PlotConfigurationTreeModel.java 文件源码
项目:rapidminer
阅读 27
收藏 0
点赞 0
评论 0
/**
* @param root
*/
public PlotConfigurationTreeModel(DefaultMutableTreeNode root, PlotConfiguration plotConfig,
PlotConfigurationTree plotConfigTree) {
super(root);
this.plotConfig = plotConfig;
this.plotConfigTree = plotConfigTree;
if (root != null) {
fillNewPlotConfigNode(plotConfig);
}
if (plotConfig != null) {
plotConfig.addPlotConfigurationListener(this);
}
}
MAMEtoJTree.java 文件源码
项目:MFM
阅读 19
收藏 0
点赞 0
评论 0
private DefaultMutableTreeNode createRamoptionNode(Ramoption ramoption) {
DefaultMutableTreeNode dmtNode = new DefaultMutableTreeNode("ramoption");
String value = ramoption.getValue();
if (value != null && !value.isEmpty()) {
dmtNode.add(new DefaultMutableTreeNode("value" + valueDivider + value));
}
String aDefault = ramoption.getDefault();
if (aDefault != null && !aDefault.isEmpty()) {
dmtNode.add(new DefaultMutableTreeNode("default" + valueDivider + aDefault));
}
return dmtNode;
}
CellRenderer.java 文件源码
项目:Luyten4Forge
阅读 31
收藏 0
点赞 0
评论 0
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
if (node.getChildCount() > 0) {
setIcon(this.pack);
} else if (getFileName(node).endsWith(".class") || getFileName(node).endsWith(".java")) {
setIcon(this.java_image);
} else if (getFileName(node).endsWith(".yml") || getFileName(node).endsWith(".yaml")) {
setIcon(this.yml_image);
} else {
setIcon(this.file_image);
}
return this;
}
NationTypeDetailPanel.java 文件源码
项目:freecol
阅读 19
收藏 0
点赞 0
评论 0
/**
* {@inheritDoc}
*/
@Override
public void addSubTrees(DefaultMutableTreeNode root) {
DefaultMutableTreeNode parent
= new DefaultMutableTreeNode(new ColopediaTreeItem(this, getId(),
getName(), null));
List<NationType> nations = new ArrayList<>();
nations.addAll(getSpecification().getEuropeanNationTypes());
nations.addAll(getSpecification().getREFNationTypes());
nations.addAll(getSpecification().getIndianNationTypes());
ImageIcon icon = new ImageIcon(ImageLibrary.getMiscImage(ImageLibrary.BELLS, ImageLibrary.ICON_SIZE));
for (NationType type : nations) {
parent.add(buildItem(type, icon));
}
root.add(parent);
}
RevertDeletedAction.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
private void retrieveDeletedFiles(final Node[] activatedNodes, final RevertPanel p) {
VCSContext ctx = VCSContext.forNodes(activatedNodes);
Set<VCSFileProxy> rootSet = ctx.getRootFiles();
if(rootSet == null || rootSet.size() < 1) {
return;
}
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
for (VCSFileProxy root : rootSet) {
PlainFileNode rfn = new PlainFileNode(root);
populateNode(rfn, root, !VersioningSupport.isFlat(root));
if(rfn.getChildCount() > 0) {
rootNode.add(rfn);
}
}
if(rootNode.getChildCount() > 0) {
p.setRootNode(rootNode);
} else {
p.setRootNode(null);
}
}
SimulationTreePanel.java 文件源码
项目:featurea
阅读 26
收藏 0
点赞 0
评论 0
/**
* Shows the a dialog allowing the user to edit the ray.
*/
private void editRayAction() {
// getProperty the currently selected body
TreePath path = this.tree.getSelectionPath();
// make sure something is selected
if (path != null) {
// getProperty the selected node
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// make sure its a ray that is selected
if (node.getUserObject() instanceof SandboxRay) {
// getProperty the ray from the node
SandboxRay ray = (SandboxRay) node.getUserObject();
// show the right dialog
synchronized (Simulation.LOCK) {
SandboxRay nRay = EditRayDialog.show(ControlUtilities.getParentWindow(this), ray);
this.simulation.getRays().remove(ray);
this.simulation.getRays().add(nRay);
node.setUserObject(nRay);
}
}
}
}
PreviewDialog.java 文件源码
项目:oxygen-dita-translation-package-builder
阅读 20
收藏 0
点赞 0
评论 0
/**
* Returns the index of a child of a given node, provided its string value.
*
* @param node The node to search its children.
* @param childValue The value of the child to compare with.
* @return The index.
*/
private int childIndex(final DefaultMutableTreeNode node, final String childValue) {
@SuppressWarnings("unchecked")
Enumeration<DefaultMutableTreeNode> children = node.children();
DefaultMutableTreeNode child = null;
int index = -1;
while (children.hasMoreElements() && index < 0) {
child = children.nextElement();
if (child.getUserObject() != null && childValue.equals(child.getUserObject())) {
index = node.getIndex(child);
}
}
return index;
}
OptionGroupUI.java 文件源码
项目:FreeCol
阅读 23
收藏 0
点赞 0
评论 0
/**
* This function analyses a tree selection event and calls the
* right methods to take care of building the requested unit's
* details.
*
* @param event The incoming TreeSelectionEvent.
*/
@Override
public void valueChanged(TreeSelectionEvent event) {
detailPanel.removeAll();
DefaultMutableTreeNode node
= (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null) {
if (node.isLeaf()) {
OptionGroup group = (OptionGroup) node.getUserObject();
for (Option option : group.getOptions()) {
addOptionUI(option, editable && group.isEditable());
}
} else {
tree.expandPath(event.getPath());
}
}
detailPanel.revalidate();
detailPanel.repaint();
}
NavigationView.java 文件源码
项目:routerapp
阅读 34
收藏 0
点赞 0
评论 0
/**
* @param e
*/
protected void itemSelected(MouseEvent e) {
if (e.getClickCount() == 2) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null) {
if (node.isLeaf())
if (node.getParent() != null) {
if (node.getParent().toString().equals("graphs")) {
for (int i=0 ; i<observers.size() ; i++)
(observers.get(i)).graphSelected(node.toString());
}
else if (node.getParent().toString().equals("animations")) {
for (int i=0 ; i<observers.size() ; i++)
(observers.get(i)).animationSelected(node.toString());
}
else if (node.getParent().toString().equals("algorithms")) {
for (int i=0 ; i<observers.size() ; i++)
(observers.get(i)).algorithmSelected(node.toString());
}
}
}
}
}
MainFrame.java 文件源码
项目:gate-core
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void actionPerformed(ActionEvent e) {
Runnable runner = new Runnable() {
@Override
public void run() {
TreePath[] paths = resourcesTree.getSelectionPaths();
for(TreePath path : paths) {
final Object userObject = ((DefaultMutableTreeNode)
path.getLastPathComponent()).getUserObject();
if(userObject instanceof NameBearerHandle) {
SwingUtilities.invokeLater(new Runnable() { @Override
public void run() {
((NameBearerHandle)userObject).getCloseAction()
.actionPerformed(null);
}});
}
}
}
};
Thread thread = new Thread(runner, "CloseSelectedResourcesAction");
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
DynFormBase.java 文件源码
项目:AgentWorkbench
阅读 22
收藏 0
点赞 0
评论 0
/**
* Provides the Vector of all currently available nodes of the same kind as the current node.
*
* @param currNode The current node of the object structure
* @return the multiple nodes available
*/
private Vector<DefaultMutableTreeNode> getMultipleNodesAvailable(DefaultMutableTreeNode currNode) {
// --- The result vector of all needed nodes ------------------------------------
Vector<DefaultMutableTreeNode> nodesFound = new Vector<DefaultMutableTreeNode>();
// --- Can we find the number of similar nodes to the current one? --------------
DynType currDT = (DynType) currNode.getUserObject();
// --- The current parentNode and the position of the current node --------------
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) currNode.getParent();
// --- Search for all similar nodes ---------------------------------------------
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeNode checkNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);
DynType checkDT = (DynType) checkNode.getUserObject();
if (checkDT.equals(currDT)) {
nodesFound.add(checkNode);
}
}
return nodesFound;
}
FileTree.java 文件源码
项目:Mujeed-Arabic-Prolog
阅读 26
收藏 0
点赞 0
评论 0
/** Construct a FileTree */
public FileTree(File dir) {
setLayout(new BorderLayout());
applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
setBorder(null);
// Make a tree list with all the nodes, and make it a JTree
JTree tree = new JTree(addNodes(null, dir));
tree.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
// Add a listener
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e
.getPath().getLastPathComponent();
}
});
add(BorderLayout.CENTER, tree);
JScrollPane scrollBarExplorer = new JScrollPane();
scrollBarExplorer.getViewport().add(tree);
scrollBarExplorer.setBorder(null);
add(scrollBarExplorer, BorderLayout.CENTER);
}
ExcludeDependencyPanel.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
private TreeNode createReferenceModel(Set<DependencyNode> nds, CheckNode trans) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(null, true);
ChangeListener list = new Listener();
List<CheckNode> s = new ArrayList<CheckNode>();
Icon icn = ImageUtilities.image2Icon(ImageUtilities.loadImage(IconResources.DEPENDENCY_ICON, true)); //NOI18N
change2Trans.put(list, trans);
change2Refs.put(list, s);
for (DependencyNode nd : nds) {
String label = nd.getArtifact().getGroupId() + ":" + nd.getArtifact().getArtifactId();
CheckNode child = new CheckNode(nd, label, icn);
child.setSelected(isSingle);
child.addChangeListener(list);
s.add(child);
root.add(child);
}
return root;
}
SimulationTreePanel.java 文件源码
项目:featurea
阅读 21
收藏 0
点赞 0
评论 0
/**
* Shows an add new joint dialog using the given joint panel.
* <p>
* If the user closes or cancels, nothing is modified. If the user clicks the add button
* a new joint is created and added to the world.
*
* @param clazz the joint class
*/
private void addJointAction(Class<? extends Joint> clazz) {
synchronized (Simulation.LOCK) {
SandboxBody[] bodies = this.getBodies();
// check the joint class type
if (bodies == null || bodies.length == 0 || (clazz != PinJoint.class && bodies.length == 1)) {
JOptionPane.showMessageDialog(ControlUtilities.getParentWindow(this), Messages.getString("menu.resources.joint.add.warning"),
Messages.getString("menu.resources.joint.add.warning.title"), JOptionPane.ERROR_MESSAGE);
return;
}
Joint joint = AddJointDialog.show(ControlUtilities.getParentWindow(this), bodies, clazz);
if (joint != null) {
// add the joint to the world
this.simulation.getWorld().addJoint(joint);
// add the joint to the root node
DefaultMutableTreeNode jointNode = new DefaultMutableTreeNode(joint);
// insert into the tree
this.model.insertNodeInto(jointNode, this.jointFolder, this.jointFolder.getChildCount());
// expand the path to the new node
this.tree.expandPath(new TreePath(jointNode.getPath()).getParentPath());
}
}
}
SwingSpyPanel.java 文件源码
项目:swingspy
阅读 23
收藏 0
点赞 0
评论 0
/**
* Recursively adds new nodes to the tree.
*/
protected void addNode(DefaultMutableTreeNode parent, Component component, Component selectedComponent) {
DefaultMutableTreeNode componentNode = new DefaultMutableTreeNode(new ComponentWrapper(component));
parent.add(componentNode);
if (component == selectedComponent) {
TreePath selectedPath = new TreePath(componentNode.getPath());
componentTree.setSelectionPath(selectedPath);
componentTree.scrollPathToVisible(selectedPath);
}
if (component instanceof Container) {
Container container = (Container) component;
Component[] childComponents = container.getComponents();
for (Component child : childComponents) {
addNode(componentNode, child, selectedComponent);
}
}
}
SimulationTreePanel.java 文件源码
项目:featurea
阅读 26
收藏 0
点赞 0
评论 0
/**
* Applies a force to the given body if the user accepts the input.
*/
private void applyForceAction() {
// the current selection should have the body selected
TreePath path = this.tree.getSelectionPath();
// make sure that something is selected
if (path != null) {
// getProperty the currently selected node
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// make sure the selected node is a body
if (node.getUserObject() instanceof SandboxBody) {
// getProperty the body from the node
SandboxBody body = (SandboxBody) node.getUserObject();
// show the force input dialog
Vector2 f = ApplyForceDialog.show(ControlUtilities.getParentWindow(this));
// make sure the user accepted the input
if (f != null) {
synchronized (Simulation.LOCK) {
body.applyForce(f);
}
}
}
}
}
HintsPanel.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
private void handleClick(MouseEvent e) {
if (e.isPopupTrigger()) {
Point p = e.getPoint();
TreePath path = errorTree.getPathForLocation(e.getPoint().x, e.getPoint().y);
if (path != null) {
DefaultMutableTreeNode o = (DefaultMutableTreeNode) path.getLastPathComponent();
if (o.getUserObject() instanceof HintMetadata) {
HintMetadata hint = (HintMetadata) o.getUserObject();
if (hint.category.equals(Utilities.CUSTOM_CATEGORY)) {
JPopupMenu popup = new JPopupMenu();
popup.add(new JMenuItem(new RenameHint(o, hint, path)));
popup.add(new JMenuItem(new RemoveHint(o, hint)));
popup.show(errorTree, e.getX(), e.getY());
}
}
}
}
}
SimulationTreePanel.java 文件源码
项目:featurea
阅读 23
收藏 0
点赞 0
评论 0
/**
* Called when the user clicks the Center On Origin menu item on a body.
*/
private void centerOnOriginAction() {
// the current selection should have the body selected
TreePath path = this.tree.getSelectionPath();
// make sure that something is selected
if (path != null) {
// getProperty the currently selected node
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// make sure the selected node is a body
if (node.getUserObject() instanceof SandboxBody) {
// getProperty the body from the node
SandboxBody body = (SandboxBody) node.getUserObject();
synchronized (Simulation.LOCK) {
// re-center the body
body.translateToOrigin();
}
}
}
}
CarTreeRenderer.java 文件源码
项目:scorekeeperfrontend
阅读 20
收藏 0
点赞 0
评论 0
/**
* Overridden DefaultTreeCellRenderer method to change the type of drawing.
* @param tree the main tree object
* @param value the value we want to display
* @param isSel if this tree node is selected
* @param isExp if this tree node is expanded
* @param isLeaf if this is a leaf node
* @param index the index of this node in the tree node array
* @param cHasFocus if the focus is on this node
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean isSel, boolean isExp, boolean isLeaf, int index, boolean cHasFocus)
{
super.getTreeCellRendererComponent(tree, value, isSel, isExp, isLeaf, index, cHasFocus);
Object o = ((DefaultMutableTreeNode)value).getUserObject();
if (o instanceof Entrant)
{
Entrant e = (Entrant)o;
String display = e.getNumber() + " - " + e.getName() + " - " + e.getCarModel() + " " + Database.d.getEffectiveIndexStr(e.getCar());
setText(display);
}
return this;
}
RLCTreeBuilder.java 文件源码
项目:rlc-analyser
阅读 17
收藏 0
点赞 0
评论 0
/**
* This method will create the configuration tab tree
*
* @param dataStore
* - the RLCDataStore that was used to collect all the data for
* the RLCs processed
* @param configurationDataStore
* - the ConfigurationDataStore that was used to collect all the
* data for the RLCs processed
* @return JScrollPane
*/
public JScrollPane createConfigurationResultsTree(final RLCDataStore dataStore,
final ConfigurationDataStore configurationDataStore) {
final DefaultMutableTreeNode top = new DefaultMutableTreeNode("root");
final ConfigurationAnalyser configurationAnalyser = new ConfigurationAnalyser(configurationDataStore);
// Populate with config tab results
final DefaultMutableTreeNode commPointAnalysis = new DefaultMutableTreeNode("Communication Points");
for (final String type : configurationAnalyser.getAllCommunicationPointTypes()) {
final List<ModifiedPropertyCountData> properties = configurationAnalyser
.getModifiedCommunicationPointPropertyCounts(type, -1);
addResultTreeNode(commPointAnalysis, "" + type + " configuration", properties);
}
top.add(commPointAnalysis);
return new JScrollPane(manipulateJTree(top));
}
OptionGroupUI.java 文件源码
项目:FreeCol
阅读 20
收藏 0
点赞 0
评论 0
/**
* Builds the JTree which represents the navigation menu and then
* returns it
*
* @param group The {@code OptionGroup} to build from.
* @param parent The tree to build onto.
*/
private void buildTree(OptionGroup group, DefaultMutableTreeNode parent) {
for (Option option : group.getOptions()) {
if (option instanceof OptionGroup) {
if (!((OptionGroup)option).isVisible()) continue;
DefaultMutableTreeNode branch
= new DefaultMutableTreeNode(option);
parent.add(branch);
buildTree((OptionGroup) option, branch);
}
}
}
RLCTreeBuilder.java 文件源码
项目:rlc-analyser
阅读 18
收藏 0
点赞 0
评论 0
/**
* This method is used to add nodes to a tree
*
* @param node
* - the node to be added to
* @param categoryName
* - the group name of the list of the items
* @param counts
* - list of counts values
*/
private void addResultTreeNode(final DefaultMutableTreeNode node, final String categoryName,
final List<ModifiedPropertyCountData> counts) {
final DefaultMutableTreeNode category = new DefaultMutableTreeNode(categoryName);
node.add(category);
for (final ModifiedPropertyCountData count : counts) {
final DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(ResultsFormatter.formatCount(count));
category.add(childNode);
}
}
XSheet.java 文件源码
项目:jdk8u-jdk
阅读 24
收藏 0
点赞 0
评论 0
public boolean isMBeanNode(DefaultMutableTreeNode node) {
Object userObject = node.getUserObject();
if (userObject instanceof XNodeInfo) {
XNodeInfo uo = (XNodeInfo) userObject;
return uo.getType().equals(Type.MBEAN);
}
return false;
}
MyTreeModel.java 文件源码
项目:UaicNlpToolkit
阅读 20
收藏 0
点赞 0
评论 0
public void valueForPathChanged(TreePath path, Object newValue) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
String name = ((String) newValue).trim();
if (node.toString().equals(name))//s-a introdus acelasi text
return;
boolean ok = true;
if (name == null || name.isEmpty()) {
ok = false;
JOptionPane.showMessageDialog(grammarEditor.frame, "The node name cannot be empty", "Error", JOptionPane.ERROR_MESSAGE);
} else if (grammarEditor.grammar.getGraphs().containsKey(name)) {
ok = false;
JOptionPane.showMessageDialog(grammarEditor.frame, "A graph with this name exists already", "Error", JOptionPane.ERROR_MESSAGE);
}
if (!ok) {
grammarEditor.graphTree.startEditingAtPath(path);
} else {
RenameGraphCommand renameGraphCommand = new RenameGraphCommand();
renameGraphCommand.graph = ((MyTreeNodeObject) node.getUserObject()).graph;
renameGraphCommand.grammarEditor = grammarEditor;
renameGraphCommand.prevName = renameGraphCommand.graph.getId();
renameGraphCommand.nextName = name;
grammarEditor.grammar.getGraphs().put(name, renameGraphCommand.graph);
grammarEditor.grammar.getGraphs().remove(renameGraphCommand.graph.getId());
renameGraphCommand.graph.setId(name);
grammarEditor.undoSupport.postEdit(renameGraphCommand);
grammarEditor.refreshTree();
}
nodeChanged(node);
}
PComplexService.java 文件源码
项目:sbc-qsystem
阅读 23
收藏 0
点赞 0
评论 0
@Override
public boolean canImport(TransferHandler.TransferSupport info) {
final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();
final TreePath tp = dl.getPath();
final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) tp
.getLastPathComponent();
return parent.getParent().getParent() == null;
}
ConfigureTree.java 文件源码
项目:VASSAL-src
阅读 26
收藏 0
点赞 0
评论 0
protected Action buildCloneAction(final Configurable target) {
final DefaultMutableTreeNode targetNode = getTreeNode(target);
if (targetNode.getParent() != null) {
return new AbstractAction("Clone") {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent evt) {
Configurable clone = null;
try {
clone = target.getClass().getConstructor().newInstance();
}
catch (Throwable t) {
ReflectionUtils.handleNewInstanceFailure(t, target.getClass());
}
if (clone != null) {
clone.build(target.getBuildElement(Builder.createNewDocument()));
insert(getParent(targetNode), clone,
targetNode.getParent().getIndex(targetNode) + 1);
}
}
};
}
else {
return null;
}
}
PathsCustomizer.java 文件源码
项目:incubator-netbeans
阅读 25
收藏 0
点赞 0
评论 0
private static DefaultTreeModel toTreeModel(final DefaultListModel lm, final String rootName) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootName);
for (int i = 0; i < lm.getSize(); i++) {
Object obj = lm.getElementAt(i);
if (obj instanceof ClassPathSupport.Item) {
root.add(toTreeNode(obj));
}
}
return new DefaultTreeModel(root);
}
MyTreeCellEditor.java 文件源码
项目:UaicNlpToolkit
阅读 18
收藏 0
点赞 0
评论 0
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
MyTreeNodeObject myTreeNodeObject = (MyTreeNodeObject) ((DefaultMutableTreeNode) value).getUserObject();
if (myTreeNodeObject.graph == null || myTreeNodeObject.graph.getId().equals("Main")) {
Toolkit.getDefaultToolkit().beep();
return renderer.getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, true); // hasFocus == true
}
return super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
}