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 / November 2003

Tip: Looking for answers? Try searching our database.

UIManager.put("CheckBox.icon... Usage?

Thread view: 
Jim Crowell - 04 Nov 2003 17:42 GMT
Hello,

I am trying to control some Look & Feel Color parameters for the JCheckBox
class. I am using Java 1.3.1

I have written a Class based on some code I found on the Internet designed
to accomplish this task. Among other things this class has a 'paintIcon'
method where my LAF adjustement are made.

I have verified with  'System.out.println' Statement that the following line
is reached during my initialization phase:

UIManager.put("CheckBox.icon", new  JTKCheckBoxIcon());
where  'JTKCheckBoxIcon' is the name of my Class to adjust the LAF
parameters.

I also have placed a 'System.out.println' Statement as the first statement
in the 'JTKCheckBoxIcon.paintIcon' class.

I never see the 'println' from my 'paintIcon' method and the test JComboBox
LAF is not modified.

I found several cases, in this forum and others, where just modifying the
UIManager "CheckBox.icon" key is suggested but now I wonder if  I need to
subclass JComboBox somehow to make this work?

Can anyone see where I have gone wrong here?

Can anyone point me to some code that I can use to print out the UIManager
parameters at the time I instance the test JComboBox object? I found one
reference in this forum but the link has gone south.

Thanks,
Jim...
Simon Righarts - 05 Nov 2003 10:12 GMT
> Hello,
>
> I am trying to control some Look & Feel Color parameters for the JCheckBox
> class. I am using Java 1.3.1

<snippage>

Here's how I did it (I had to override the default, because I had
dark-background JPanels, and the default 'tick' doesn't show up on those):

in init(),main() or wherever you initialise the GUI:

....
 UIManager.put("CheckBox.icon", new MyCheckIcon()); //black tick on dark
background = bad
....

and the MyCheckIcon class is:

import javax.swing.plaf.metal.*;
import javax.swing.*;
import java.awt.*;

public class MyCheckIcon extends MetalCheckBoxIcon{

   protected void drawCheck(Component c, Graphics g, int x, int y) {
 Color old = g.getColor();
 g.setColor(DomCalculator.tickColor); // see note
 int controlSize = getControlSize();
 g.fillRect( x+3, y+5, 2, controlSize-8 );
 g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
 g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
 g.setColor(old);
   }
}

/* DomCalculator.tickColor for my project was a public static data field ...
replace with whatever colour tick you want.
Also, if you're using a different LAF, replace the metal import/name by the
proper ones for your LAF */
Jim Crowell - 05 Nov 2003 14:12 GMT
Simon,
> Here's how I did it (I had to override the default, because I had
> dark-background JPanels, and the default 'tick' doesn't show up on those):
[quoted text clipped - 5 lines]
> background = bad
> ....

My problem is that somehow my UIManager.put("CheckBox.icon", ... operation
is not being registered OR the registration is being corrupted somewhere.
When I received this response I added a System.out.println statement to my
'drawCheck' Method also but I never get there.

Look like from your response and other examples I found on the Intrernet
that I am doing what I should be doing but something in my code is messing
up the UIManager processing.

Thanks,
Jim


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.