JTextBox w/ context menu?

can a jtextbox have a context drop down?

i have many text boxes on a form, and for some of these id like to have a "suggestion list" .

for example they want to place a order, and instead of typing the amount in a case they can simply right click and select "1 case" or "2 cases" , and it simply calculates the amount. this amount is retrieved from a db file which stores all this information.

any ideas?

thanks

[444 byte] By [llpindda] at [2007-10-3 10:04:03]
# 1
wouldn't that be a .... combo box?
dberanskya at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 2

yea....

but i already have a bunch of textboxes and dont want to change it... its a late request.and second... i dont want it to select what they choose...but to fire a action which in turn calculates the amount and sets it.a editable combobox will simply set the field they choose from the list?

but id really like a solution where i dont have to change 100 textboxes to comboboxes, but instead add the functionality.

llpindda at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 3
hi!then you prepare a JList and add it into a JScrollpane, after that show that in a JPopupMenu. I hope that will be a better solution..:)
Aniruddha-Herea at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 4
Whats a JTextBox?
camickra at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 5
i guess he is talking about javax.swing.JTextField
Aniruddha-Herea at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 6
> i guess he is talking about ...Don't guess. People need to learn how to ask clear accurate questions with all the relevant information if they want clear accurate solutions.
camickra at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 7
lol... yes i mean JTextField.sorry...yesterday was a long day.
llpindda at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 8

> hi!

> then you prepare a JList and add it into a

> JScrollpane, after that show that in a JPopupMenu. I

> hope that will be a better solution..

>

> :)

after searching a bit, i found this by santhosh http://www.javalobby.org/java/forums/t19867.html

but I don抰 want all my textfields to have this behavior. So a mouse listener (added only to the ones i want) showing a popup on right-click, built using how u described, would be the best solution for this?

although i will still need to add the listener to a bunch of textfields.

thanks

llpindda at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 9
hi!infact i am doing this in one of my project. that is why i have suggested this. maybe someone else can give any other solution, but in this regards this is the best according to me:)
Aniruddha-Herea at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...
# 10
I guess thats the way to do it.thanks anirud
llpindda at 2007-7-15 5:23:11 > top of Java-index,Desktop,Core GUI APIs...