• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Append a String to an ImageIcon

 
Shannon Sims
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a way to append a string to an ImageIcon?

Thank you.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand what you are asking about. Please elaborate...
 
Shannon Sims
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja,
In my JTable that takes a AbstractTableModel, I am trying to update the header name with an Up arrow image. So when the user clicks on the header, the data will sort in the table and the header will display the "name + the up arrow". My Swing book shows how to do something like this however I wanted to try a simpler approach. I've created a method in my JTable that pulls a column name from an array and appends an image to the String, however this does not work.

Thanks,
-Shannon
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code that doesn't work, please? Remember to use code-tags to preserve formatting...
 
Shannon Sims
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja,
Unfortunately, I do not have access to the internet at home. Therefore, I will have to provide you with the code tomorrow, but searching through the posts, it looked as though using the JLabel would have worked. However trying that didn't work. I couldn't get the fireTableStructureChange() to updated the column header with the icon, tried using repaint(), updateUI(), setVisible( true ), ect, but still the header would not display the icon. From my not-so-good memory, here's what I did:



I'm fairly new to Swing, so I'm learning as I go. Thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic