Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert an existing text box into a combo box  RSS feed

 
Jerome Jabson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!