• 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

Make String display bold or italic

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way that I can display a String in Bold (preferably) or Italics. I am using JCTable (Sitraka class). When I get certian value from the server I want to display that field as bold. Can someone help me with this?? Thanks!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

We've got a forum devoted to Swing and AWT issues; I'll move this there.
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most SWING components will allow you to include html markup to affect their display. So if you can, you might want to try intercepting that special value if you find it, and surrounding it with <html><b> and </b></html>.

The only other way I can think of is kind of a pain in the butt. You essentially need to create your own TableCellRenderer and apply that to the particular field when that special value occurs. The crux of what you would do would be to add code like this to your JTable class (assuming that you are subclassing JTable):


and then add an inner class something like this:

Essentally, from my understanding, every table cell is rendered by a TableCellRenderer, and every table implements a default, sinple TableCellRenderer that basically just displays plaintext (I guess underlying that is a simple JLabel). If you want a table cell to appear as anything other than just plaintext, you need to create your own TableCellRenderer that returns a JComponent that will display the value for that table cell.

I've simplified it a bit, but it should at least point you in the right direction.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I tested the methos posted by "dave taubler" and found that the specialValue mentioned "x", would not serve the purpose. Which means if i have a value x that verfies to true, then the entire table rows will be bolded. Instead only custom renderer could be used to serve the purpose. Suppose based on the column cell value at position 4,we can decide whether the whole row field should be bolded or not. Check out the custom cell renderer below;



Cheers
Kiran
 
kiran raja
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I tested the methos posted by "dave taubler" and found that the specialValue mentioned "x", would not serve the purpose. Which means if i have a value x that verfies to true, then the entire table rows will be bolded. Instead only custom renderer could be used to serve the purpose. Suppose based on the column cell value at position 4,we can decide whether the whole row field should be bolded or not. Check out the custom cell renderer below;



Cheers
Kiran
 
Sheriff
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ed Nigma hasn't been active for over 4 years. http://faq.javaranch.com/java/DontWakeTheZombies
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic