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

The Archive Base Latest Questions

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

This has been asked a million times it appears, but I must be feeling

  • 0

This has been asked a million times it appears, but I must be feeling especially dense tonight because I’m still having trouble. My first question is this, when I call

ImageIcon icon = new ImageIcon(getClass().getResource("images/x.jpg"));

where is it looking for the images folder? I’ve tried making it a folder under my project and under src. What am I missing? I’m using Eclipse. As you’ve probably guessed already, I haven’t done much Java.

What I really want to do is to set the the first column in a table to an initial icon and then allow the user to double click on it and change the icon. Could someone be so kind as to gently push (or violently shove) me in the right direction? Do I need my own renderer class?

class MyRenderer extends DefaultTableCellRenderer {
....

When someone double clicks on the row I want to change the icon to y.jpg.

Edited
Thanks for the help. Another dumb question. Should I see the icon when I add a row like this?

DefaultTableModel dm = (DefaultTableModel)tblNews.getModel();
ImageIcon icon = new ImageIcon(getClass().getResource("/x.jpg"));
dm.addRow(new Object[]{icon, "Text"});

I see the filename of the icon, but not the icon itself.

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

    1) your ImageIcon could be placed for
    (new ImageIcon(getClass().getResource("images/x.jpg"));)

    • src

      • MyPackage

             - MyClass.java
        
      • MyPackage/images

                   - x.jpg
        

    more Packaging in Java

    2) JTable knows Icon / ImageIcon as Object, then there no reason set for Icon in the Renderer

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

Sidebar

Related Questions

I know this has been asked a million times before but i still can't
I'm sure this has been asked a million times, but what is the accepted
I know that this has been asked a million times before, but nothing that
I know this has probably been asked a million times, but how do I
You're probably thinking this has been asked a million times before but I think
I know this has kinda been asked a million times but I wanted to
I know this has been asked a million times, but I haven't had much
I think this has been asked a million times, but with different definitions of
Hey all, I know this question has been asked a million times before but
This has been asked few times but I think it's still worth checking with

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.