Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Java Questions...

    Hi i am trying to learn Java but i have some problems... If you can help me ...

    I want to know how i can show dynamicaly the fonts provided by my operating System in a choise (Fonts =new Choice()?

    I want also need a choice for changing the colors of a string... I know how to create some colors in the choice...
    Choice Fontcolor=new Choice();
    Fontcolor.addItem("Red");
    Fontcolor.addItem("Blue");

    Do u know something better than this? For example something that i can use it immediately for changing the color.... I was thinkink if it is possible instead of text colors ..... to use colored lines in the choice... Is this possible?

    Finally how i can change the color of a String?
    I have a String inside a TextArea...i can;t find any option for this? Any suggestion?
    Thx

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For the TextArea, I think you have to use setForeground() to change the colour of the text. A String doesn't have a color property, neither does Font (to my knowledge..).

    I don't know of anyway to 'loop through' the available fonts on the system. You pretty much have to know the name of the font you want.

    You may want to use a color chooser as opposed to the dropdown thing you've got. Take a look at this tutorial:
    http://java.sun.com/docs/books/tutor...orchooser.html

    Hope that helps,
    Sadiq.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    thx

    thx again.... Of course it wil be veru helpful if someone knew ... how i could change the color of the Text

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You'd change the colour of the TextArea's foreground using setForeground() to change the colour of the text.

    If you're drawing a string to the screen, you need to set the colour of the Graphics object you're using.

    Sadiq.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    thx

    If you can hel me more...Can u give some more code... I only want to change the Font Color in my TextArea


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •