aspose file tools*
The moose likes Beginning Java and the fly likes JCheckBox works but doesn't toggle graphically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JCheckBox works but doesn Watch "JCheckBox works but doesn New topic
Author

JCheckBox works but doesn't toggle graphically

Joshua Amy
Greenhorn

Joined: Dec 17, 2011
Posts: 12
I'm trying java's swing for the first time with a problem from "Art and Science of Java" with a little program that allows users to fill the canvas with stars upon mouse clicking. I'm trying to make a JCheckBox on the SOUTH border that allows the user to toggle between filled and unfilled stars. The button works properly except that the check mark doesn't toggle when clicked. Otherwise it actually will toggle the stars to be filled or not. Can someone please show me my mistake? Thanks in advance.

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4527
    
    5

As Michael said in your thread about a similar problem with JSlider the problem is likely to be in your custom classes.

What keeps you from using classes from the standard JDK? Not everyone has the acm/acmx classes that are required to be able to compile and run your code to try and find out what might be wrong.


luck, db
There are no new questions, but there may be new answers.
Joshua Amy
Greenhorn

Joined: Dec 17, 2011
Posts: 12
Darryl, thanks for the reply. My reason for the custom classes is only ignorance. I started programming Java watching the Stanford Intro to Programming videos, and Stanford also had some packages to get students started in Eclipse...perhaps this is where my problem lies? As for the code, I copied it directly from "Art and Science of Java" after discovering that the problem happened in several of my programs...I thought I might be doing something wrong repeatedly. The only difference may be that my imports vary slightly (Eclipse does automatic importing, and sometimes I find that my book has imports that are extraneous).

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
Beware: Eclipse has a habit of importing classes in alphabetical order, so classes whose package names begin com. appear before classes beginning java. If you import a class beginning com. because it comes top on Eclipse’s list, that is probably the wrong class. Check your imports carefully for that error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCheckBox works but doesn't toggle graphically