• 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

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

 
Ranch Hand
Posts: 36
Eclipse IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic