|
-
calling methods
Im using a progress Panel for a typing tutor. When the typing lesson ends I cannot do anything else with the Progress Panel e.g. resetting a lesson. Other less important buttons work e.g. changing the colour and font sizes etc.
The buttons are created by an action Listener. It all works perfect untill the lesson ends, and the progress panel freezes.
What is the correct way to call an action Listener method so that it will work when the lesson is completed?
Here is some of the code im using.
boolean isCorrectKey = progressPanel.type( charTyped );
if( progressPanel.atEnd() ) {
currentLessonLine++;
switch (lessonNumber) {
case 1:
if (currentLessonLine < lesson1.length) {
progressPanel.setText(lesson1[currentLessonLine]);
currentLessonLine++;
break;
}
case 2:
if (currentLessonLine < lesson2.length) {
progressPanel.setText(lesson2[currentLessonLine]);
currentLessonLine++;
break;
}
default: // end of lesson
javax.swing.JOptionPane.showMessageDialog(null, progressPanel.message());
javax.swing.JOptionPane.showMessageDialog(null, progressPanel.getResults());
/*
* Close off lesson - more typing will cause exceptions - exceeding array bounds
*/
//}
}
}
public void lessonbutton_ActionPerformed(ActionEvent event) {
if(lessons.getSelectedItem() == "Lesson 1"){
progressPanel.setText( lesson1[currentLessonLine] );
mainheading.setText("Lesson 1: The home keys");
lessonNumber =1;
}
else if(lessons.getSelectedItem() == "Lesson 2") {
progressPanel.setText( lesson2[currentLessonLine] );
mainheading.setText("Lesson 2: 'g' and 'h' keys");
lessonNumber =2;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks