This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse Plugin Development-Creating a Wizard Page with dynamic components

 
Saraswathi Mukkai
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am developing an Eclipse Plugin with Wizard and Wizard Page Extension.

Right now I am able to build static Wizard Pages with components like Buttons, Text Boxes etc.

How can I build dynamic Wizard Pages? i.e., Wizard Pages with Components like Buttons and Text Boxes added during Run-Time?

Thanks!!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

You can add and remove Components from other GUI components at any time with the add and remove methods. Just be careful about Layouts, because the whole thing may change shape when you do so. You can also keep Frames or Dialogs which become visible(true) or visible(false) as required.

Does that help you?
[ July 10, 2008: Message edited by: Campbell Ritchie ]
 
Saraswathi Mukkai
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell Ritchie,

Thanks for your reply and suggestion. Your answer however doesn't totally satisfy the requirement I am looking for.

What I am trying to do in the project is:

The user has to enter the "Number of variables" in a text box. If the user enters "4" in the text box, then 4 text boxes have to be added below the above text box during runtime on the same page. If the user types 2 in the "Number of variables" text box then only two text boxes have to be added on the same page.

This is equivalent to adding "Components" to a page dynamically. How will I be able to do it at runtime?

Thanks!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47232
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are probably hundreds of possible solutions, but how about this:-
  • Parse the text to work out how many JTextFields you require.
  • Create a JTextField[] array.
  • Iterate through that array and add that JTextField.
  • You can use the array index to determine the location if you use something like GridBagLayout.
  • It might be better to use a JSpinner to choose the number of components, since spinners can be set to return numbers.
     
    Harsh Gehlot
    Greenhorn
    Posts: 1
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Isn't it a better way to use
    this.getControl().getParent().layout(true,true) ...


    Originally posted by Campbell Ritchie:
    [Q]There are probably hundreds of possible solutions, but how about this:-
  • Parse the text to work out how many JTextFields you require.
  • Create a JTextField[] array.
  • Iterate through that array and add that JTextField.
  • You can use the array index to determine the location if you use something like GridBagLayout.
  • It might be better to use a JSpinner to choose the number of components, since spinners can be set to return numbers.[/Q]
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic