File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox

 
Lydia Su
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic