Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assigning jcombobox items

 
Wolfgang Rolf
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
million thanks mate!

rolf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic