• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JCheckBox works but doesn't toggle graphically

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Joshua Amy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).

 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic