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?
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?
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Apr 27, 2001
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?
Joined: Sep 29, 2000
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.