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.
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.
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.
Joined: May 23, 2005
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?
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?
Joined: May 23, 2005
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?
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: editable JCombobox need help getting text from user