File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Close...but no cigar? Help with Check boxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Close...but no cigar? Help with Check boxes" Watch "Close...but no cigar? Help with Check boxes" New topic
Author

Close...but no cigar? Help with Check boxes

jodi clark
Greenhorn

Joined: Jul 13, 2004
Posts: 10
Im new to java and the whole java swing/awt thing....i have the following code but am obviously missing something and dont get what it is. Any help would be GREATLY appreciated =0)




i get the following errors:

C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:19: cannot resolve symbol
symbol : class JCheckbox
location: class extra
public JCheckbox ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:33: cannot resolve symbol
symbol : class JCheckBoxListener
location: class extra
JCheckBoxListener cblistener = new JCheckBoxListener();
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:33: cannot resolve symbol
symbol : class JCheckBoxListener
location: class extra
JCheckBoxListener cblistener = new JCheckBoxListener();
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:35: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch1 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:36: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch2 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:37: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch3 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:38: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch4 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:39: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch5 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:40: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch6 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:41: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch7 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:42: cannot resolve symbol
symbol : constructor JCheckBox (boolean)
location: class javax.swing.JCheckBox
ch8 = new JCheckBox(true);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:54: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch1=new JCheckBox ("CB-CAT5E-1 1M CAT.5E UTP CABLE RJ45M",cbox,false);
^

C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:58: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch2=new JCheckBox ("CB-CAT5E-10 10M CAT.5E UTP CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:62: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch3=new JCheckBox("CB-CAT6-1 1M AT6 UTP CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:66: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch4= new JCheckBox("CB-CAT6-10 10M CAT6 UTP CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:70: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch5=new JCheckBox("CB-CAT5ECS-2 2M CAT.5E UTP CROSSOVER CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:74: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch6=new JCheckBox("CB-CAT5ECS-10 10M CAT.5E UTP CROSSOVER CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:78: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch7=new JCheckBox("CB-CAT6CS-2 2M CAT6 UTP CROSSOVER CABLE RJ45M", cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:82: cannot resolve symbol
symbol : constructor JCheckBox (java.lang.String,java.awt.CheckboxGroup,boolean)
location: class javax.swing.JCheckBox
ch8=new JCheckBox("CB-CAT6CS-10 10M CAT6 UTP CROSSOVER CABLE RJ45M",cbox, false);
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:160: incompatible types
found : double
required: javax.swing.JTextField
answer = 2.86;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:163: incompatible types
found : double
required: javax.swing.JTextField
answer =12.98;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:166: incompatible types
found : double
required: javax.swing.JTextField
answer = 6.60;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:169: incompatible types
found : double
required: javax.swing.JTextField
answer = 16.34;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:172: incompatible types
found : double
required: javax.swing.JTextField
answer = 4.40;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:175: incompatible types
found : double
required: javax.swing.JTextField
answer = 14.30;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:178: incompatible types
found : double
required: javax.swing.JTextField
answer = 19.60;
^
C:\Documents and Settings\Jodi\My Documents\TAFE Stuff\Programming\Java\Major Assignment\extra.java:181: incompatible types
found : double
required: javax.swing.JTextField
answer = 35.60;
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
Hi Jodi,

See How to Use Buttons, Check Boxes, and Radio Buttons in the Java Tutorial.

You can use the ButtonGroup class to cover a set of JRadioButton objects, but there is no such thing in the JDK as a CheckBoxGroup.

Ed


The nice thing about Standards is that there are so many to choose from!
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Originally posted by Eddie Vanda:
there is no such thing in the JDK as a CheckBoxGroup.

Well, not with a capital B but: CheckboxGroup is alive and well and living in the java.awt package.

On the other hand javax.swing.JCheckBox does have a capital B, unlike in the above swathe of code, hence the compilation error. Consistency is a wonderful thing. :roll:

Jules
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Jodi,

I spent a little time looking at your problems and I'm afraid the prognosis is not good. If your program was a horse ... 'nuff said!

Before I go into specifics I think you should take Eddie's advice and spend some time learning about Java and Swing by following some simple tutorial examples. Even if you choose not to take that advice you should develop your program in baby steps, compiling it every line or two and also running it frequently to make sure it's doing what you want and that your changes haven't broken it.

I don't want to discourage you but I think you're a long way off getting your program to work. It took me nearly 10 minutes to get it to compile! I don't dare run it.

Here are some pointers:
  • Sort out your indentation - you'll find it hard enough to follow your code without half of it being out of line
  • You have class called MessageBox (extends Component) that is not in the J2SE 1.4 API. Are you using J2SE 5.0 (Tiger)? Or is MessageBox a class that exists in a Swing framework that you're working with. Or maybe just a placeholder for a class you intend to include? Anyway, you need to import it or define it if you're using J2SE 1.4.
  • Your private CheckBoxListener class doesn't begin with a J (your references to it do)
  • Make the API docs your friend. It'll save you a lot of time doing this!
  • I say the above as, in two cases, you're attempting to call versions of the JCheckBox constructor that don't exist. Again this may be Tiger for all I know, but I'd have my money on it being you. Are you converting an old AWT program/example or something? I guess it could be that too.
  • You have an instance variable named answer which is a JTextField. You later try to use answer to receive a double. You need to use a different name for the double local variable.
  • Also, if you have time, familiarise yourself with Java coding style conventions. Stuff like all class names begin with a capital letter. It's the style you'll see in most books and examples on the web and it makes your code much easier to read for others (and hopefully for you) if you use it. Make a conscious effort to get into the habit - it's a good one.


  • I think that's about it, though I may have missed something. Anyway, even after sorting all that out I've no idea whether your code will work. As I say, I'd recommend taking some time out to learn stuff properly. Start again if necessary. Prune your code back to the bare minimum and get it to compile and work (run correctly) in little steps. You don't need to throw away what you've done but perhaps copy and paste new bits as they're needed. Above all, keep it simple: you've got enough to worry about learning the language without overcomplicating your code and application into the bargain.

    I hope you find this to be of some help.

    Jules
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Close...but no cigar? Help with Check boxes