File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes assigning jcombobox items Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "assigning jcombobox items" Watch "assigning jcombobox items" New topic

assigning jcombobox items

Wolfgang Rolf

Joined: Aug 10, 2004
Posts: 2

i have a jcombobox with items ranging from 5 to -5. my idea is whenever a user selects an item, a point in the form of 'filloval' will be plotted in a rectangle on the jpanel. the problem right now is that when i select the 5 value from the material ratings combobox & press the plot button the 'filloval' isn't drawn at the correct place which is supposed to be at the top of the material ratings box.

my question is how can i assigned the values of the jcombobox let say 5 = 20. i tried using bigger numbers for the items but the results were the same.

probably my explaination isn't that clear. below is my code. please run it & you'll see the problem. if anyone out there has any idea of solving this problem please let me know. thanks in advance.

Sebastiaan Kortleven
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
You take the height of the rectangle, divide it by 10 (difference between MIN and MAX value) and you multiply the selection of the user by this nr.. that gives you a lineair connection between the combobox and the plotted point
Wolfgang Rolf

Joined: Aug 10, 2004
Posts: 2
million thanks mate!

I agree. Here's the link:
subject: assigning jcombobox items
It's not a secret anymore!