Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

jspinner foreground problem

Thread view: 
Lou Lipnickey - 08 Mar 2005 19:47 GMT
I have a custom JTable renderer extending JSpinner. It seems that I
cannot set the foreground or background colors ( setForeground(color)
and setBackground(color) don't change any colors). Anyone have any
suggestions? - Lou
Roland - 09 Mar 2005 08:42 GMT
> I have a custom JTable renderer extending JSpinner. It seems that I
> cannot set the foreground or background colors ( setForeground(color)
> and setBackground(color) don't change any colors). Anyone have any
> suggestions? - Lou
jSpinner = new JSpinner();
JComponent editor = jSpinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
    JSpinner.DefaultEditor defEditor = (JSpinner.DefaultEditor) editor;
    JFormattedTextField tf = defEditor.getTextField();
    if (tf != null) {
        tf.setBackground(Color.RED);
        tf.setForeground(Color.WHITE);
    }
}

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Lou Lipnickey - 10 Mar 2005 03:17 GMT
Thanks, I also got the following to work:

JFormattedTextField tf =
((JSpinner.DefaultEditor)this.getEditor()).getTextField();
    if (isSelected)
        {
        tf.setForeground(table.getSelectionForeground());
        tf.setBackground(table.getSelectionBackground());
    }
    else
    {
        tf.setForeground(table.getForeground());
        tf.setBackground(table.getBackground());
    }

>> I have a custom JTable renderer extending JSpinner. It seems that I
>> cannot set the foreground or background colors ( setForeground(color)
[quoted text clipped - 11 lines]
>     }
> }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.