aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to show hashmap value in a textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to show hashmap value in a textbox" Watch "how to show hashmap value in a textbox" New topic
Author

how to show hashmap value in a textbox

anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
i have done a hashmap and when i click one of the option in a combobox i want the hasmap value to appear in a textbox i prepared. how do i do that?..i am not using any database for my project. thank you in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Would it be fair to guess that this "textbox" is a Swing JTextField? If it is, then you call "setText(value)" on it.

Anyway, let us know because answering questions based on guesswork is rather a waste of time. (That's why I just gave a short answer.) Then we can move the post to the correct forum -- this isn't the right forum, unless you want to tell us which "other API" you had in mind. And read our FAQ page TellTheDetails (follow that link) to see what other information you could provide.
anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
yes it is a jtext field

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Swing? Okay, let's move it to the Swing forum then.

And I added code tags to the post, so the code is more readable.

Also, don't use == to compare the contents of two String objects, use the String's equals() method instead.

Okay. So... what was your question again? You're iterating through a HashMap's entries, but what exactly do you want to do with them?
anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
oo ok . thanks for that tip. well i put in a Jcombobox and and JtextField. so everytime i choose sumthing from the combobox i want the value to be seen in the textfield. for example, when i click switch name in the combobox, i want the textfield to show that value which is 1.3.6.1...(sorry cant remember the value) as i have put in the coding where switch name = 1.3.6.1.2.... so how should i do that sir?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

There are two steps:

(1) Get the value from the map.

(2) Put it into the text field.

It isn't clear to me which of those two steps you are having trouble with; at any rate, iterating through the map shouldn't be required, so you could delete that code.
anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
get the value from the map and put it in the textfield.. its like the user selects the choise from the Jcombobox and the value from the selection will appear in the textfield. example i have a bunch of value and key : router name =1.3.6.1.2.3.4 then switch name=1.2.3.4.5.3 then switch value=1.2.3.5.2.. therefore the user just need to choose the name list from the combobox list which are switch name, router name, switch value. then when they choose for example switch name the value "1.2.3.4.5.3" should appear at the textfield.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

anne annette, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/new-java/61703-how-show-hashmap-value-textbox.html

In that thread, you were given a link to a tutorial on Swing event listeners. Have you gone through the tutorial?


luck, db
There are no new questions, but there may be new answers.
anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
yes i did post in the forum and also in other several forums but i did not understand. and yes i did read it and try it out but it was not successful. sorry i did not mentioned it earlier.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

anne annette wrote:... and yes i did read it and try it out but it was not successful.

And don't you think Tolls, who gave you that link, would like to know that?
anne annette
Greenhorn

Joined: Apr 22, 2012
Posts: 8
excuse me MR.DARRYL when i said it was not successful i did not mean his posting i meant my attempt to understand the link was not successful and i did not know how to implement it and yes I WILL WRITE TO HIM BACK . i am very new to this forums and java that i am posting so i am not clear with the rules here but that does not mean you can write whatever you want and make a misunderstanding here. if you do not want to help its find. please do not create misunderstanding. thank you.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> ...i meant my attempt to understand the link was not successful...

that's how it reads to me.
you need to explain what you tried, and how it wasn't successful.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Anne, can you please BeNice and KeepItDown? Darryl is just doing his job as Bartender, informing you of one of our FAQ entries and why we encourage people to follow it. There is no need to snap back at him, especially in upper case letters.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to show hashmap value in a textbox