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 7492643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:30:04+00:00 2026-05-29T16:30:04+00:00

I am using a JTree , and I am traversing the tree using an

  • 0

I am using a JTree, and I am traversing the tree using an Enumerator.

TreeModel columnTreeModel = columnTree.getModel();
TreeNode columnTreeRoot = (TreeNode) columnTreeModel.getRoot();
Enumeration<TreeNode> columnTreeEnumerator =
    ((DefaultMutableTreeNode) columnTreeRoot).breadthFirstEnumeration();

I get a warning in the 3rd line in this code. The warning is

The expression of type Enumeration needs unchecked conversion
    to conform to Enumeration

How do I reslove this warning?

  • 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-05-29T16:30:05+00:00Added an answer on May 29, 2026 at 4:30 pm

    DefaultMutableTreeNode exists since Java 1.2, Java Generics exists since 1.5. That is why the result of the method breadthFirstEnumeration does not have a type parameter, it is a “raw” enumeration. Same for the TreeModel. You could write a parametrized TreeModel that returns a typed root node so you wouldn’t need to cast. But it just wasn’t possible at the time Swing was designed.

    You can’t “resolve” this warning without changing the type (e.g. subclassing). Just set a @SuppressWarnings("unchecked") annotation (and document why you do so) then the warning will vanish.

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

Sidebar

Related Questions

When using a JTree , a user object of a DefaultMutableTreeNode can be set.
I'm using a custom TreeModel for a JTree. I have an issue when I
I wrote a file tree using JTree, and now I am trying to make
In Swing when using a JTree/JList/JTable selecting an item changes its background color. Is
I've got a JTree which I'm using to display some (unsurprisingly) hierarchical data. Part
I have a JTree which I give objects that implement the TreeNode interface, and
I have a JPanel panel which contains a JTree tree . Sometimes the JTree
I have 2 trees in my program. Iam using JTree's clearselection() method to clear
Say my JTree consists of following nodes. new DefaultMutableTreeNode(DisplayThisTextOnly {donotdisplaystringsinhere}); how can I hide
I've got a custom tree cell renderer that I'm using to render custom icons

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.