jtree

JTree File Filter and Folder Filter

三世轮回 提交于 2020-01-15 14:07:46
问题 I want to have a JTree which display's all the files with only ".h" extension in my current directory, and it should display all the folders, except a folder named 'System Volume Information', in my current directory, here's my code, what addition.. updation i need to do ?? import java.awt.BorderLayout; import java.awt.Container; import java.io.File; import java.util.Collections; import java.util.Vector; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JPanel;

JTree File Filter and Folder Filter

北城余情 提交于 2020-01-15 14:05:05
问题 I want to have a JTree which display's all the files with only ".h" extension in my current directory, and it should display all the folders, except a folder named 'System Volume Information', in my current directory, here's my code, what addition.. updation i need to do ?? import java.awt.BorderLayout; import java.awt.Container; import java.io.File; import java.util.Collections; import java.util.Vector; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JPanel;

Get Attribute XML in JTree

好久不见. 提交于 2020-01-15 08:14:42
问题 In this tutorial, how I get attribute of xml when I right click delete menu, then show the dialog with the value of attribute? 回答1: In deleteAction , you can reference clickedPath.getLastPathComponent() to access the selected node. 来源: https://stackoverflow.com/questions/11790390/get-attribute-xml-in-jtree

Get Attribute XML in JTree

蓝咒 提交于 2020-01-15 08:14:11
问题 In this tutorial, how I get attribute of xml when I right click delete menu, then show the dialog with the value of attribute? 回答1: In deleteAction , you can reference clickedPath.getLastPathComponent() to access the selected node. 来源: https://stackoverflow.com/questions/11790390/get-attribute-xml-in-jtree

JTree TreeCellRenderer raising issue on showing the selection color

不问归期 提交于 2020-01-14 16:49:09
问题 I am using this below piece of code: class CountryTreeCellRenderer implements TreeCellRenderer { private JLabel label; CountryTreeCellRenderer() { label = new JLabel(); } public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Object o = ((DefaultMutableTreeNode) value).getUserObject(); if (o instanceof Country) { Country country = (Country) o; label.setIcon(new ImageIcon(country.getFlagIcon()));

JTree TreeCellRenderer raising issue on showing the selection color

天大地大妈咪最大 提交于 2020-01-14 16:47:28
问题 I am using this below piece of code: class CountryTreeCellRenderer implements TreeCellRenderer { private JLabel label; CountryTreeCellRenderer() { label = new JLabel(); } public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Object o = ((DefaultMutableTreeNode) value).getUserObject(); if (o instanceof Country) { Country country = (Country) o; label.setIcon(new ImageIcon(country.getFlagIcon()));

Convert JTree to XML

梦想的初衷 提交于 2020-01-14 06:29:05
问题 I've seen many many articles on how to read XML into a JTree but few on how to create the XML from the JTree. Can anyone help me with a simple approach for this? I've seen an example that looked like: XMLEncoder e = new XMLEncoder( new BufferedOutputStream(new FileOutputStream(f.toString()))); e.writeObject(o); e.close(); .. but I can't get this to work; it returns an XML file but its not quite right, looking like this: <java version="1.6.0_17" class="java.beans.XMLDecoder"> <object class=

Assign DefaultMutableTreeNode to JTree

£可爱£侵袭症+ 提交于 2020-01-13 21:10:41
问题 I am developing a small desktop application in Netbeans. I drag and drop a JTree on my JFrame and now i want to fill the node hierarchy of this this JTree dynamically. For this i worte a method which return me DefaultMutableTreeNode object. Now how do i assign this object to the JTree which i drag and drop 回答1: following example will help you to do it package commondemo; /** * * @author hemant */ import java.awt.*; import javax.swing.*; import javax.swing.tree.*; public class SimpleTree

Assign DefaultMutableTreeNode to JTree

一笑奈何 提交于 2020-01-13 21:07:32
问题 I am developing a small desktop application in Netbeans. I drag and drop a JTree on my JFrame and now i want to fill the node hierarchy of this this JTree dynamically. For this i worte a method which return me DefaultMutableTreeNode object. Now how do i assign this object to the JTree which i drag and drop 回答1: following example will help you to do it package commondemo; /** * * @author hemant */ import java.awt.*; import javax.swing.*; import javax.swing.tree.*; public class SimpleTree

Can I use runtime parameters to fix out of bad API calls in Java?

旧城冷巷雨未停 提交于 2020-01-13 02:41:14
问题 Not sure if this is the right spot to ask but I'm having a Java issue. I have some Java code that works in Java 6 but not in Java 7, the error is: java.lang.IllegalStateException: This function should be called while holding treeLock Using Java6 works but a few of our external users are running Java 7. I figured out the error was caused by a call to validateTree() , which works in java6 but in Java7 we need to call validate() . When I test it locally it works. Here's my problem, I started