PDA

View Full Version : Dynamic button creation



shekhar12
07-26-2004, 11:24 AM
I have created a Custom dialog "DialogTest" and in initializeUI event method I tried to create a button dynamically. Below given is the piece of code.


public void initializeUIdialogTest(com.installshield.event.ui.ISDialogContext arg0)
{
ISButtonDef button = arg0.getISFrame().getFrameDefinition().createButton();
button.setX(20);
button.setY(20);
button.setVisible(true);
button.setText("Test Button");
button.setEnabled(true);
button.setDefaultButton(true);
button.setDefaultFocus(true);
}

then in the sequence I inserted this dialog after welcome dialog. But when I run the project the dialog appears but the button is not visible. Please tell me how to make this button visible.

Abhishekhar

brianl
07-26-2004, 11:22 PM
This is actually a bug with the API...you should not have access to designtime APIs in the runtime. The panels are not meant to be dynamically configurable in the runtime.

Instead, you should add the button in the dialog editor, and set its Visible property to false. Then set Visible to true when you need in code by


ISButton myButton = arg0.getISFrame().getButton(MY_BUTTON);
myButton.setVisible(true);