• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to show hashmap value in a textbox

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it is a jtext field

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
anne annette
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> ...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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic