Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-05-2007, 06:03 AM
Member
 
Join Date: Jul 2007
Posts: 35
carl is on a distinguished road
Change the color in my program
Hi, I am trying to learn Java but i have some problems.
I want to know how i can show dynamically the fonts provided by my operating System in a choice 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...
Code:
Choice Fontcolor=new Choice(); Fontcolor.addItem("Red"); Fontcolor.addItem("Blue");
Do you know something better than this? For example something that i can use it immediately for changing the color.... I was thinking 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?
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-05-2007, 07:26 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
The GraphicsEnvironment class has a couple of handy methods you can use to get the fonts and their names.
Code:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); String[] names = ge.getAvailableFontFamilyNames();
is possible instead of text colors ..... to use colored lines in the choice... Is this possible?
I don't think you could do this in the AWT. I think you could in Swing by making a custom renderer for a JComboBox.
Usually, I would use an array of Colors and fetch the color using the selectedIndex of the Choice.

how i can change the color of a String? I have a String inside a TextArea
TextArea supports only a single color and font. For multiple colors and fonts you will need to use a JTextPane and a StyledDocument.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A bit of color! tim Java 2D 8 02-12-2008 12:57 AM
How to change font/ font color etc in a graphic object using JCombobox? JavaInLove AWT / Swing 0 02-07-2008 12:28 PM
How to change TXT color Onclick dave700800 New To Java 1 12-08-2007 02:39 AM
Help with switch color Daniel AWT / Swing 1 07-05-2007 07:43 AM
How to change color of JTable row having a particular value johnt AWT / Swing 2 05-31-2007 10:13 PM


All times are GMT +3. The time now is 01:55 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org