Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8794
| From | Knute Johnson <nospam@knutejohnson.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Attempting to set the color of a JTextField |
| Date | 2011-10-14 07:21 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <j79ghg$4lm$1@dont-email.me> (permalink) |
| References | <c72ebf3b-6aad-457c-be87-5d7a992e0d9e@h5g2000vbf.googlegroups.com> |
On 10/14/2011 7:15 AM, John L. wrote:
> 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.
See setOpaque(), setForeground() and setBackground()
--
Knute Johnson
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
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