Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you set the color of an array List of JTextArea

 
Jacob Coddaire
Ranch Hand
Posts: 36
Chrome Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are defined in the field.

These are defined in the method.


What i'm trying to do is the following:
1. Scan for a String and make it the name of the player
2. That name then gets assigned a user specified color via JColor Chooser
3. The data is stored in an arrayList of type Player, which is defined in the Player class
4. I then add type player to the GUI by using a JTextArea

Here's where I'm having trouble.
5. The displayed text should show the specified color in step 2.

getColor cannot be used for type Color: it wants me to change it to a string. However, that is not what I want to do.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can't set the color to an ArrayList. May be on a JTextArea? Extract each element in the ArrayList then add set the color....
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can set every line of a JTextArea to a different color. Why don't you use a JList? Then you can specify the colour for each cell.
And I don't think you want a nested loop.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic