Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:37:43+00:00 2026-06-15T22:37:43+00:00

I’m using Fest in order to check if two entries have the same icon.

  • 0

I’m using Fest in order to check if two entries have the same icon.

I’m actually having a JTreeFixture, from what i can access a specific entry with its path.

JTreeFixture tree = getTreeFromWindow();
JLabel label  = (JLabel) tree.selectPath("/folder2/entry2").component.getCellRenderer();

JLabel labe2  = (JLabel) tree.selectPath("/folder2/entry3").component.getCellRenderer();

I’m getting two JLabel(s), but they both point to the last entry in my folder2.
Since it seems Fest cant help me much here, i’m planning to use the JTree directly (thanks to JTreeFixture.component() => returns the JTree) , and extract the informations directly from the JTree.

How can i get a JLabel included in a JTree, knowing the entry’s path ?

SOLVED :
I created this method :

public Icon getIconeFromPath(String path){
    JTreeFixture tree = getTreeFromWindow();
    PreMadeCellRenderer renderer = (PreMadeCellRenderer) tree.component().getCellRenderer().;
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.clickPath(path).component().getLastSelectedPathComponent();
    JLabel label = (JLabel) renderer.getTreeCellRendererComponent(tree.component(), node, true, true, true, 0, true);
    return label.getIcon();
}

getTreeFromWindow returns a JTreeFixture
PreMadeCellRenderer is a renderer extending DefaultTreeCellRenderer
getTreeCellRendererComponent returns a component, and its arguments are explained here http://docs.oracle.com/javase/7/docs/api/javax/swing/tree/TreeCellRenderer.html

I used the parameter 0 because i didnt knew what to put in, and worked 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:37:44+00:00Added an answer on June 15, 2026 at 10:37 pm

    Swing uses the same shared JLabel object for painting all the tree nodes (for performance reasons). I would recommend checking the user object (typically a String) of the tree node.

    Also see this:
    Difficulties understanding the renderers mechanism of swing's JTable and JTree

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.