• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Append a String to an ImageIcon

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Is there a way to append a string to an ImageIcon?

Thank you.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand what you are asking about. Please elaborate...
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic