Changes

Jump to: navigation, search
no edit summary
=== 5. Add Elements to View Screen ===
5.1. Create new Class <code>InfoScreen</code> that extends <code>MainScreen</code> as inner class in MyScreen:<br/>
<presource lang="java">
private final static class InfoScreen extends MainScreen {
InfoScreen(Student student) {
}
}
</presource>
5.2. Set the title:
<presource lang="java">
setTitle(student.toString());
</presource>
5.3. Add the text field:
<presource lang="java">
BasicEditField emailField = new BasicEditField("email: ",student.getEmail(),50,Field.NON_FOCUSABLE);
add(emailField);
</presource>
5.4. Format this field:
<presource lang="java">
Border roundedBorder = BorderFactory.createRoundedBorder(new XYEdges(10, 10, 10, 10), Border.STYLE_SOLID);
Background solidBackground = BackgroundFactory.createSolidBackground(Color.CORAL);
emailField.setBorder(roundedBorder);
emailField.setBackground(solidBackground);
</presource>
5.5. Override the ,code>close()</code> method:
<presource lang="java">
public void close() {
Dialog.alert("Quit");
super.close();
}
</presource>
5.6. Some mehtods inside the <code>MyScreen</code> should be overriden. <br>
In order to show the View screen override the <code>invokeAction()</code> method:
<presource lang="java">
public boolean invokeAction(int action) {
if(action == ACTION_INVOKE) {
return super.invokeAction(action);
}
</presource>
5.7. If enter was hit we want to show the view Screen:
<presource lang="java">
protected boolean keyChar(char key, int status, int time) {
if (key == Characters.ENTER) {
return super.keyChar(key, status, time);
}
</presource>
5.8. Override the <code>onSavePrompt()</code> to suppress the save dialog:
<presource lang="java">
public boolean onSavePrompt() {
return true;
}
</presource>
5.9. Create the method to push the view screen into the stack:
<presource lang="java">
private void displayInfoScreen(){
// Retrieve the selected Country and use it to invoke a new InfoScreen
}
}
</presource>
5.10. Run the application and click on a student:<br/>
[[Image: BB_view.png | 300px]]
1
edit

Navigation menu