aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Eclipse Plugin Development-Creating a Wizard Page with dynamic components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Eclipse Plugin Development-Creating a Wizard Page with dynamic components" Watch "Eclipse Plugin Development-Creating a Wizard Page with dynamic components" New topic
Author

Eclipse Plugin Development-Creating a Wizard Page with dynamic components

Saraswathi Mukkai
Greenhorn

Joined: Jul 09, 2008
Posts: 2
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

Joined: Oct 13, 2005
Posts: 36579
    
  16
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

Joined: Jul 09, 2008
Posts: 2
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

Joined: Oct 13, 2005
Posts: 36579
    
  16
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

    Joined: Dec 10, 2008
    Posts: 1
    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]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Eclipse Plugin Development-Creating a Wizard Page with dynamic components
     
    Similar Threads
    Best Framework for Tabbed Dialogs
    static and dynamic portion
    Eclipse and Swing
    Help with JFace Wizard.
    Adding a Container Listener to a panel