Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8792

Attempting to set the color of a JTextField

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!feeder1-1.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!h5g2000vbf.googlegroups.com!not-for-mail
From "John L." <johnlarew@sbcglobal.net>
Newsgroups comp.lang.java.programmer
Subject Attempting to set the color of a JTextField
Date Fri, 14 Oct 2011 07:15:11 -0700 (PDT)
Organization http://groups.google.com
Lines 23
Message-ID <c72ebf3b-6aad-457c-be87-5d7a992e0d9e@h5g2000vbf.googlegroups.com> (permalink)
NNTP-Posting-Host 99.36.3.16
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1318601711 7615 127.0.0.1 (14 Oct 2011 14:15:11 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 14 Oct 2011 14:15:11 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info h5g2000vbf.googlegroups.com; posting-host=99.36.3.16; posting-account=vHb1bwkAAACXOLEGUF3lwjcdjcbRncDb
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order ARLUEHNKC
X-HTTP-UserAgent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; yie8),gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8792

Show key headers only | View raw


I'm trying to change the color of a JTextField. There are many
interesting discussions on much more detailed topics in other posts.

Here is my best attempt, which does NOT work as I might reasonably
expect:

class ITextField extends JTextField
{
   private String s1 = null;
   public void setText(String s) {
      s1 = s;
   }
   public void paintComponent(Graphics g) {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D) g;
      if (s1 != null) {
         g2.setPaint(Color.RED);
         g2.drawString(s1,0,0);
      }
   }
}

Thanks in advance for any help or insight you may be able to provide.

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Attempting to set the color of a JTextField "John L." <johnlarew@sbcglobal.net> - 2011-10-14 07:15 -0700
  Re: Attempting to set the color of a JTextField Knute Johnson <nospam@knutejohnson.com> - 2011-10-14 07:21 -0700
    Re: Attempting to set the color of a JTextField "John L." <johnlarew@sbcglobal.net> - 2011-10-14 08:05 -0700
      Re: Attempting to set the color of a JTextField Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-14 10:42 -0700
        Re: Attempting to set the color of a JTextField "John L." <johnlarew@sbcglobal.net> - 2011-10-19 07:16 -0700
  Re: Attempting to set the color of a JTextField Roedy Green <see_website@mindprod.com.invalid> - 2011-10-14 09:44 -0700

csiph-web