This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Append a String to an ImageIcon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Append a String to an ImageIcon" Watch "Append a String to an ImageIcon" New topic
Author

Append a String to an ImageIcon

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hello,
Is there a way to append a string to an ImageIcon?

Thank you.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I don't understand what you are asking about. Please elaborate...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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

Joined: Jul 11, 2001
Posts: 14112
Can you show us the code that doesn't work, please? Remember to use code-tags to preserve formatting...
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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.
 
 
subject: Append a String to an ImageIcon
 
Similar Threads
Line Feed Carriage Return problem
.append() method
how do I make an array like this?
null
HELP! me pls i can't open image on JLabel