PDA

View Full Version : [CLOSED] Cannot add Button to FormPanel



cdasher
24 Apr 2008, 6:55 AM
I am trying to add some buttons to a FormPanel and they never display

final Window window = new Window();
window.modal = true;
window.shadow = false;
window.maximizable = true;
window.setWidth(600);
window.setHeight(400);

window.setLayout(new FillLayout());


if (nodeType.equals("DEVICE") && windowType.equals("add")){
final boolean enabled = true;
final FormPanel<Field> panel = new FormPanel<Field>();




TextField nameField = new TextField();
nameField.setEmptyText("Device Name");
nameField.fieldLabel = "Name";
nameField.setEnabled(enabled);
nameField.setTitle("Device Name");
nameField.setToolTip("This is the name of the device");
panel.add(nameField);


TextArea descriptionField = new TextArea();
descriptionField.setEmptyText("Description");
descriptionField.fieldLabel = "Description";
descriptionField.setEnabled(enabled);
panel.add(descriptionField);

CheckBox ignoreRomRadio = new CheckBox();
ignoreRomRadio.fieldLabel = "Ignore Rom Id";
ignoreRomRadio.setEnabled(enabled);
panel.add(ignoreRomRadio);

TextField startingDenaField = new TextField();
startingDenaField.setEmptyText("Starting DENA");
startingDenaField.fieldLabel = "Starting DENA";
startingDenaField.setEnabled(enabled);
panel.add(startingDenaField);

TextField endingDenaField = new TextField();
endingDenaField.setEmptyText("Ending DENA");
endingDenaField.fieldLabel = "Ending DENA";
endingDenaField.setEnabled(enabled);
panel.add(endingDenaField);

CheckBox ignoreDenaRadio = new CheckBox();
ignoreDenaRadio.fieldLabel = "Ignore DENA";
ignoreDenaRadio.setEnabled(enabled);
panel.add(ignoreDenaRadio);

TextField familyIdField = new TextField();
familyIdField.setEmptyText("Family ID");
familyIdField.fieldLabel = "Family ID";
familyIdField.setEnabled(enabled);
panel.add(familyIdField);

TextField modelNumberField = new TextField();
modelNumberField.setEmptyText("Model Number");
modelNumberField.fieldLabel = "Model Number";
modelNumberField.setEnabled(enabled);
panel.add(modelNumberField);

Button saveButton = new Button("Save");
saveButton.addListener(Events.Click, new Listener<BaseEvent>(){

public void handleEvent(BaseEvent be) {
Info.display("CLICK","SAVE", "");

}});

Button cancelButton = new Button("Cancel");
saveButton.addListener(Events.Click, new Listener<BaseEvent>(){

public void handleEvent(BaseEvent be) {
window.close();

}});

Button restButton = new Button("Reset");
saveButton.addListener(Events.Click, new Listener<BaseEvent>(){

public void handleEvent(BaseEvent be) {
for (Field f : panel.getItems()){
f.reset();
}

}});

panel.add(saveButton);
panel.add(cancelButton);
panel.add(restButton);

panel.header = false;
panel.shadow = false;
panel.layout(true);

window.add(panel);
window.layout(true);
window.show();

darrellmeyer
24 Apr 2008, 7:15 AM
Try using panel.addButton(btn);