hello!

m new to java.i want to create an application that accepts length x width from combo box.there are 100 values.i want to draw a rectangle whose size will change for each value in a combo box depending on its length and width.
which method should i use?
can any one help me?

Thanx in advance...

hello!

m new to java.i want to create an application that accepts length x width from combo box.there are 100 values.i want to draw a rectangle whose size will change for each value in a combo box depending on its length and width.
which method should i use?
can any one help me?

Thanx in advance...

which method should i use?

Impossible to say without further information.

There are several parts to this task:

  • Setting up the GUI with a Combo Box and a panel to draw the rectangle on.
  • Putting the values into the combo box.
  • Having the program extract the length/width string from the combo box when the user selects the size.
  • Parsing the combo box selection into integers.
  • Drawing the rectangle with the right width/length.

So you need to decide what on that list you can and can't do. The methods to use depend on which part of the task you're referring to and how you have set things up.

Thanx for rply.

values in combo box are 4.8 x 2.4 , 4.8 x 2.3,..,4.7 x 2.3,..,01 x 01.and so on.
do i need to write code for each combo box item? or is it possible to write only 1 condition?

You add a Listener for the Combo Box which gets called when the user selects an item from the Combo Box. within that Listener, you grab the item/String selected and parse that String into two Integers. Then draw the Rectangle. If you are writing code for every option in the JComboBox, you're doing it incorrectly.

http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

Thanx for help...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.