• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

GUI like the Internet Explorer

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I have posted previously about this problem,but I haven't got a solution as yet.I am using swings to create my application which has some feature of the IE that is the editable combobox and a button(in case of IE,the place where you enter the URL and the go button).My application should work like wise...i mean whether user clicks button or presses enter after typing in the combo,a particular task has to be performed.Is this possible in swings??
I have been encountering a number of problems with the editable combobox and the button.I have tried writing action listener as well as key listener for the combo,but i've not been able to do the task.Please can anyone give me an idea if this is possible or not and which listener to use for application to work as described above?
All suggestions are appreciated.

Thejaswini.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can dream it, you can do it! (By the way, its called "Swing", not "swings" -- note the name of this forum, for example. I don't know who started calling it "swings").
 
thejaswini ramesh
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeff.Made note of the fact that its "Swing" and not "Swings"...
But the problem is in the actionPerformed,2 events are firing when you press enter - 'comboBoxEdited' and 'comboBoxChanged' and 3 evnts for the go button('go' along with 'comboBoxEdited' and 'comboBoxChanged').Now suppose i print the typed text(am supposed to display in a textarea),then the same text is displayed twice or thrice...this is whats causing me the problem as am supposed to display the text once whether i press enter key or click the go button.Can you suggest a way to work around this??

Thanks,
Thejaswini.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by thejaswini ramesh:

But the problem is in the actionPerformed,2 events are firing when you press enter - 'comboBoxEdited' and 'comboBoxChanged' and 3 evnts for the go button('go' along with 'comboBoxEdited' and 'comboBoxChanged').Now suppose i print the typed text(am supposed to display in a textarea),then the same text is displayed twice or thrice...this is whats causing me the problem as am supposed to display the text once whether i press enter key or click the go button.Can you suggest a way to work around this??



Hmmm... I didn't realize this your original question...

As a matter of GUI design, the JButton may be viewed as redundant, because action events are fired when you make a selection, even if it is the same as the current selection, or if you press VK_ENTER when focus is on the JComboBox. So it is up to you to decide if you want to include the JButton -- many users may prefer to use it.

If reacting to *all* the action events causes you to react multiple times to the same selection, ask youself how you would want your GUI to react if the user keeps clicking on the JButton. Do you react to each event or ignore the latter clicks? Do ever react by clearing the selection?

As for the muliple events generated by typing into the JComboBox followed by VK_ENTER, note the ActionEvent's actionCommand: it will be "comboBoxChanged" versus "comboBoxEdited" (versus the button's label when the button is clicked). Thus your listener can distinquish between these types of events and react as you dictate.
 
What a show! What atmosphere! What fun! What a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic