Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Filtering the JTree Node

 
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
 
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic