Forums Register Login

editable JCombobox need help getting text from user

+Pie Number of slices to send: Send
Hi i've looked at the tutorials and all over google.. but i just can't seem to get how i can make a combobox, editable.
Then if the user selects from the drop down list i want to grab that in a string... or if a user types something in the field and then presses a button, I want to grab the text.. I guess i'm having trouble understanding the hierarchy of events... really hope someone can help here.
+Pie Number of slices to send: Send
imrang dude

Welcome to Javaranch. Perhaps you overlooked it but we do have a Naming Policy the prohibits the use of obviously fake names. If you could adjust your display name to meet our guidelines, that would be great.

Thanks.
+Pie Number of slices to send: Send
done... do you er... have any tips for my question ?
+Pie Number of slices to send: Send
Thanks for changing your display name.

Have you been through any of Sun's JComboBox Tutorials? I believe it will answer most if not all your questions. If you get stuck on something specific let us know and we can try and help. If I were to answer your current question(s) I'd just be writing Sun's tutorial all over again.
+Pie Number of slices to send: Send
yea i read it sooo many times... but when u creat a combobox and make it editable, I can't see what part of the code will get text from the field the user enters, i know the get selectedItem selects from the dropdown.. let's say he types in an ip address and clicks a button called connect... as soon as he doesnt that how do u grap the ip into a string?
+Pie Number of slices to send: Send
If you doing it with the click of a button

+Pie Number of slices to send: Send
Yo that works amazing! thank you... btw the captured string can i store in a variable and using on setText for a label some where?
+Pie Number of slices to send: Send
 

Originally posted by imran ibrahim:
Yo that works amazing! thank you... btw the captured string can i store in a variable and using on setText for a label some where?



Yep.
+Pie Number of slices to send: Send
hmm i tried that and when i do it ... i press the connect buttoni get this:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Client.applyLabel(Client.java:243)
at Client$1.actionPerformed(Client.java:59)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
any ideas?
+Pie Number of slices to send: Send
So can I see the code?
+Pie Number of slices to send: Send
hey sorry dude... i figured it out. i had no idea that creating a label after a button would cause such problems..damn... seems like i had to create the label first or it would always cause a null pointer error.. damn...
I'm full of tinier men! And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 7548 times.
Similar Threads
How to create editable table in struts
display contents of a text file in a new window
Toggling between writable and readonly for a text box
How to include word doc in jsp
Editable Select Box ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:07:08.