private void addButtons() { loginButton = new Button("Login"); loginButton.setChangeListener(this); cancelButton = new Button("Cancel"); cancelButton.setChangeListener(this); buttonManager = new HorizontalFieldManager(FIELD_HCENTER); buttonManager.setPadding(PADDING); add(buttonManager); }
private void layoutScreen() { Button loginButton; if (settings.isUserLoggedIn()) { loginButton = new Button("Log Out"); loginButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onLogOutButtonClicked(); } }); } else { loginButton = new Button("Log In"); loginButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onLoginButtonClicked(); } }); } Button newChildButton = new Button("Register Child"); newChildButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onNewChildClicked(); } }); Button viewChildrenButton = new Button("View All Children"); viewChildrenButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onViewChildrenClicked(); } }); searchButton = new Button("Search for a Child"); searchButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onSearchClicked(); } }); Button synchronizeButton = new Button("Synchronize"); synchronizeButton.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { onSynchronizeClicked(); } }); Vector buttonGroup = new Vector(); buttonGroup.addElement(loginButton); buttonGroup.addElement(newChildButton); buttonGroup.addElement(viewChildrenButton); buttonGroup.addElement(searchButton); buttonGroup.addElement(synchronizeButton); Button.setOptimimWidthForButtonGroup(buttonGroup); VerticalFieldManager manager = new VerticalFieldManager(FIELD_HCENTER); manager.setPadding(PADDING); loginButton.setPadding(PADDING); manager.add(loginButton); newChildButton.setPadding(PADDING); manager.add(newChildButton); viewChildrenButton.setPadding(PADDING); manager.add(viewChildrenButton); searchButton.setPadding(PADDING); manager.add(searchButton); synchronizeButton.setPadding(PADDING); manager.add(synchronizeButton); add(manager); }