• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Convert an existing text box into a combo box

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I'm trying to to modify an existing class in a large application. The problem I am running into trying to convert an existing text box into a combo box when a user clicks on a button. The code right now uses a grid layout. I tried to just add the combo box in the method that creates the panel with .setVisible(false), thinking that when the listener for the button is selected I can set it to true. However, what happens is the formatting of the panel shifts everything over even if the combo box is invisible. The reason I am changing the text box into a combo box in the first place is that there is a certain scenario where the user needs to edit this panel and then processes the values when the button is selected. It is only in this panel that the button can be selected. Other parts of the application can insert data in the text box for display, hence the reason why I can not change the text box into a combo box.

I would appreciate any help or pointers anyone can give me on this. I've pretty much exhausted all resources here. Last resort is to just build the panel in the button listener method, which is really not an elegant solution.

Thanks for your help,
Jerome
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may be misinterpreting what you are trying to do, but perhaps a CardLayout will help you here. You can place both the combobox and the text box (what's a text box?) on a JPanel (if this is Swing) that uses a CardLayout. Then if you want to swap components you tell the CardLayout to change the component it shows. It's quite fun and easy to use. For more details, check out the Sun tutorials on this.
 
Jerome Jabson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pete,

Thanks I'll try that out. I'm using SWT/Jface in Eclipse PDE.

Jerome
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, my bad for assuming. I thought you were using Swing and so my advice only applies to this. You'll have to try something else if you are coding in SWT / JFace. Best of luck.

Jerome Jabson wrote:Thanks I'll try that out. I'm using SWT/Jface in Eclipse PDE.

 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic