Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Filtering the JTree Node  RSS feed

 
Ranganath Junpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have couple of problems,
1) I want to know how to filter the JTree Nodes say If i want to just show up the nodes which has .java as the extension how to go about it. I am using the TreeModel with the JTree
2) How to add the component to the JTabbedPane's Tab. IE i have a JTabbedpane with 2 tabs. If i wanna add some component to either of these tabs how to do this.

please let know about these
Thank you
Regards
Ranganath.s
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how to filter the JTree Nodes say If i want to just show up the nodes which has .java as the extension how to go about it.
The File api has a listFiles method that accepts a FileFilter in which you can specify the extension(s) you want for you TreeModel data. If you are using a JFileChooser, there is a FileFilter (different package) that works for it.
How to add the component to the JTabbedPane's Tab. IE i have a JTabbedpane with 2 tabs. If i wanna add some component to either of these tabs how to do this.
For initial use try tabbedPane.addTab(String title, Component component) to see what that does. If there is a component in the tab and you want to replace it you can try setComponentAt(int index, Component component). If there is a component in the tab and you want to add a component to this child component you can get a reference to the component (child of the tab) and add your component it. The JTabbedPane class api has methods you can use to find your way around.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!