• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JComboBox

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i use two combo boxes together? i want to draw either a line, rectangle or circle in either magenta, cyan, red, blue or green. i need to link these two up together, how can i do it using the combo box?
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you could have 2 combo boxes and a "submit" button. When the user clicks the submit button you check the selected options on the combo boxes.
Is that even CLOSE to what you are asking?
 
Lydia Su
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i don't mind the button but i have no idea on how to make the combo box draw the shapes...i've tried several ways with lots of errors,...anyone have any ideas?
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would need to put an ActionListener on the Button, and then in the actionPerformed(ActionEvent e) method of the Listener you put in the code to call repaint() to refresh the screen. Then in the paint() method (that repaint will call for you) you put the actual code to do the drawing.
The stuff that you are talking about are methods in the Graphics class. There is a drawLine() method, and a drawRect() method etc. You can also set the color by using the setForeground(Color c) method of Component.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic