Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8800
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Attempting to set the color of a JTextField |
| Date | 2011-10-14 09:44 -0700 |
| Organization | Canadian Mind Products |
| Message-ID | <gjpg9719ghi1ekci3687tmdq155ph65c0r@4ax.com> (permalink) |
| References | <c72ebf3b-6aad-457c-be87-5d7a992e0d9e@h5g2000vbf.googlegroups.com> |
On Fri, 14 Oct 2011 07:15:11 -0700 (PDT), "John L."
<johnlarew@sbcglobal.net> wrote, quoted or indirectly quoted someone
who said :
>I'm trying to change the color of a JTextField. There are many
>interesting discussions on much more detailed topics in other posts.
There is no need to override paintComponent just to change colours:
final JFrame jFrame = new JFrame();
final Container contentPane = jFrame.getContentPane();
final JTextField textfield = new JTextField( "this is a
TEST" );
textfield.setBackground( Color.BLACK );
textfield.setForeground( Color.YELLOW );
see http://mindprod.com/jgloss/jtextfield.html
If fooling around with paintComponent just to experiment
see http://mindprod.com/jgloss/paintcomponent.html
The trick is setOpaque.
--
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.
Back to comp.lang.java.programmer | Previous | Next — Previous 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