• 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

Assigning Font Color to Variable

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've made a new variable in the following way: String Hello = "Hello".
Is there a way that I can assign a font color to that variable, such as Hello.fontColor(Color.green); or something? I'm new to JDK and Eclipse so I wouldn't know.

any help is appreciated
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No you can't.  Its a String and String class doesn't have any such property.  What is your exact requirement?
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Strings don't have a color, they're just a character sequence. Once you display them somewhere, color might become relevant. So: where do you want to display them?
 
Amy Whitaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:No you can't.  Its a String and String class doesn't have any such property.  What is your exact requirement?



Basically I wanna store the word in a variable, so I can use it throughout the program by listing the variable. But there's another variable, Goodbye, and I want them each to be a different font color without having to change the font color in a new line every time I do it. Hello and Goodbye probs doesn't make sense but it's a weird program lmao
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fair enough.  But where are you displaying the output?  Is this AWT/Swing based program, is this a web application?  You can't display any formatted text in console.
 
Amy Whitaker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:Fair enough.  But where are you displaying the output?  Is this AWT/Swing based program, is this a web application?  You can't display any formatted text in console.



AWT/Swing, I'm using GTerm in Eclipse for code because it's what I've been taught on this online video series I'm doing
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So can you post your code and show us what you have done so far?
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic