If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Don't mix the AWT and Swing components together. Use JCheckBox instead of Checkbox.

I think I misunderstood what you wanted here, but the code doesn't really show what you want either. Are you trying to pick out the highest value based on the selected items? I can think of an easy way to do that with Hashtables, or a bound model on a JList instead (checkboxes don't actually store a value to them).

Is this for a school assignment or for something non-educational? The class name make it look almost like an assignment.

I can show you how to do it with the JList, but if its for an assignment I can pretty much guarantee its not covered (so of course that is a nice way of saying you can't just use it). It also only uses strings for the data; you would want to use objects so you can store the name and size together and fetch them as necessary (can also be used if the Model is custom implemented off of an extended collection class since you can then use the Collections.min in conjunction with an object of type Comparable). But it would give you the overall idea.

If you are doing this for a class, there is nothing wrong with checking each item individually as you've done. If you are looking for a max value, you simply keep track of what the max is, and replace it as necessary as you check each checkbox item. The override handling of the JList's primary advantage over that is that it will:
1. Combine the display to the value you want to contain within it (as you will be using an object). So you can retrieve it at any time from the model
2. It allows you to simply add to it without needing to modify the underlying code.

When run you should see what appears to be 3x checkboxes. Checking them will send to system.out the values you have checked (so launch from the command line to see it).

I'm not sure if this is for a school assignment, but if it is then I'd say overriding the renderers and using collections (and possibly arrays?) would be out of the question, but only you can confirm if that's the case and if so where you are. Sometimes simplicity does have its place, especially in the learning process (albeit ultimately being way more code; I could add another 20 items to that list at a cost of only 20x more lines, but to do the same with just variables would require the variables + the code to process them).

No its not a school assignment its a personal project.
Well I have no idea whats going on in this code, I think its above my level of java knowledge.
But thanx I will work through it and hopefully get some good knowledge out of it!