Java Reference
In-Depth Information
4. Change the actionPerformed method for the Settings button to read as shown in
Listing 3-10.
Listing 3-10. The actionPerformed Method for the Settings Button
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_jButton2ActionPerformed
controller.showSettingPanel();
}
5. Add the following instance variable to SettingPanel :
WeatherController controller;
6. Change the SettingPanel 's constructor to read as shown in Listing 3-11.
Listing 3-11. Revising the SettingPanel's Constructor
public SettingPanel( WeatherController c ) {
controller = c;
initComponents();
}
7. Change the SettingPanel 's Back button's actionPerformed method to read as shown
in Listing 3-12.
Listing 3-12. Revising the SettingPanel's Back Button's actionPerformed Method
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_jButton1ActionPerformed
controller.showMainPanel();
}
To see this working, you can simply build and run the application again, but this
time, try using the source-level debugger by placing a breakpoint on the line that reads
layout.replace( mainPanel, settingPanel );
in the showSettingPanel of the WeatherController class. To do this, place the cursor on the
line and click in the window margin on the left, or select Run Toggle Breakpoint from
 
Search WWH ::




Custom Search