• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

assigning jcombobox items

 
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.


 
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
 
Paper beats rock. Scissors beats tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic