text Color Question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: text Color Question

Hybrid View

  1. #1
    Ed Guest

    text Color Question


    Hi,

    I was hoping someone could point me in the right direction for the following:

    I need to have a textfield area(or something similar) which can display different
    colored background and text for each and every character in the textfield(or
    a similar type area). So for example, if I have the word "Hi". I may want
    the background color of the letter "H" to be blue with the actual text colort
    to be yellow. And I may want the letter "I" to have a background
    color of red with a text color of green. I hope this is easy to
    understand. Also, this text will be changing constantly depending on userinput.

    Anyways I am new to Java and was hoping someone could point me in the right
    direction so I don't spin my wheels forever. This is not for an applet but
    rather a full Java Program.

    Thanks

  2. #2
    Patrick Lentz Guest

    Re: text Color Question


    Ed,

    don't take my word for it because I'm a newbee myself, but it sounds like
    you should make an array of textfields that are by themself all defined as
    being one character long. Then I assume you can make all the textfield backgrounds
    a different color, if a textfield has that function,which you can look up
    in the Java Sun docs. You can do something with the random Math function
    to give the backgrounds a random backgroundcolor then.
    Hope this helps any )

    Patrick

    "Ed" <nospamefink1@nycap.rr.com> wrote:
    >
    >Hi,
    >
    >I was hoping someone could point me in the right direction for the following:
    >
    >I need to have a textfield area(or something similar) which can display

    different
    >colored background and text for each and every character in the textfield(or
    >a similar type area). So for example, if I have the word "Hi". I may want
    >the background color of the letter "H" to be blue with the actual text colort
    >to be yellow. And I may want the letter "I" to have a background
    >color of red with a text color of green. I hope this is easy to
    >understand. Also, this text will be changing constantly depending on userinput.
    >
    >Anyways I am new to Java and was hoping someone could point me in the right
    >direction so I don't spin my wheels forever. This is not for an applet

    but
    >rather a full Java Program.
    >
    >Thanks



  3. #3
    Ed Guest

    Re: text Color Question


    Hi,

    Thanks for the suggestion, it sounds like it would probably work. BUT...the
    only problem is I am going to be needing this feature for lots of text....so
    an array like this might get extrememly cumbersome and eat lots of memory
    . The problem is that MOST of the time the text will simply be black on
    white, but needs the capability to have different background colors for each
    character of text. On another messageboard someone suggested I look into
    "StyleConstants".

    Ed....

    "Patrick Lentz" <ing_patrick@hotmail.com> wrote:
    >
    >Ed,
    >
    >don't take my word for it because I'm a newbee myself, but it sounds like
    >you should make an array of textfields that are by themself all defined

    as
    >being one character long. Then I assume you can make all the textfield backgrounds
    >a different color, if a textfield has that function,which you can look up
    >in the Java Sun docs. You can do something with the random Math function
    >to give the backgrounds a random backgroundcolor then.
    >Hope this helps any )
    >
    >Patrick
    >
    >"Ed" <nospamefink1@nycap.rr.com> wrote:
    >>
    >>Hi,
    >>
    >>I was hoping someone could point me in the right direction for the following:
    >>
    >>I need to have a textfield area(or something similar) which can display

    >different
    >>colored background and text for each and every character in the textfield(or
    >>a similar type area). So for example, if I have the word "Hi". I may want
    >>the background color of the letter "H" to be blue with the actual text

    colort
    >>to be yellow. And I may want the letter "I" to have a background
    >>color of red with a text color of green. I hope this is easy to
    >>understand. Also, this text will be changing constantly depending on userinput.
    >>
    >>Anyways I am new to Java and was hoping someone could point me in the right
    >>direction so I don't spin my wheels forever. This is not for an applet

    >but
    >>rather a full Java Program.
    >>
    >>Thanks

    >



  4. #4
    Paul Clapham Guest

    Re: text Color Question

    Since this is for a Java program you should be using Java2. Look into the
    Java documentation for the package javax.swing.text, which "Provides classes
    and interfaces that deal with editable and noneditable text components."
    Being new to Java you'll probably find this overwhelming, but eventually I
    think it will do what you want. Also, the main page of this package's
    documentation refers to a tutorial at
    http://java.sun.com/docs/books/tutor...ents/text.html which
    you may find useful.

    Good luck!

    Ed <nospamefink1@nycap.rr.com> wrote in message
    news:393e8eb7$1@news.devx.com...
    >
    > Hi,
    >
    > I was hoping someone could point me in the right direction for the

    following:
    >
    > I need to have a textfield area(or something similar) which can display

    different
    > colored background and text for each and every character in the

    textfield(or
    > a similar type area). So for example, if I have the word "Hi". I may want
    > the background color of the letter "H" to be blue with the actual text

    colort
    > to be yellow. And I may want the letter "I" to have a background
    > color of red with a text color of green. I hope this is easy to
    > understand. Also, this text will be changing constantly depending on

    userinput.
    >
    > Anyways I am new to Java and was hoping someone could point me in the

    right
    > direction so I don't spin my wheels forever. This is not for an applet

    but
    > rather a full Java Program.
    >
    > Thanks




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center