Skip to content

Commit 7f33acc

Browse files
committed
added icons, working on FancyMesageBox w/@samanthalangit
1 parent 3b510a8 commit 7f33acc

18 files changed

Lines changed: 21 additions & 28 deletions

File tree

src/main/java/org/teachingextensions/logo/utils/EventUtils/FancyMessageBox.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
package org.teachingextensions.logo.utils.EventUtils;
22

3+
import javax.swing.ImageIcon;
34
import javax.swing.JOptionPane;
45

56
import org.teachingextensions.approvals.lite.util.NumberUtils;
67

78
/**
8-
* <img src=
9-
* "http://www.mhhe.com/engcs/compsci/wu2/graphics/wu2java/common/javabook2Doc/mbox3.gif"
9+
* <img src="http://www.mhhe.com/engcs/compsci/wu2/graphics/wu2java/common/javabook2Doc/mbox3.gif"
1010
* style="text-align: left" alt="A message box" height="60" width="145"> <br>
11-
* <br>
12-
* <br>
13-
* <br>
14-
* <br>
1511
* Fancy MessageBox is a pop up window that you can change!<br>
16-
* Use it to collect numerical input from the user<br>
17-
* Or to display a message for the user to read.<br>
12+
* Use it to collect input from the user, or to display a message for the user to read.<br>
1813
*/
1914
public class FancyMessageBox
2015
{
@@ -58,16 +53,16 @@ public static String askForTextInput(String message, String title)
5853
* @param title
5954
* the title of the FancyMessageBox
6055
*/
61-
public static void showMesage(String message, String title)
56+
public static void showMesage(String message, String title, ImageIcon icon)
6257
{
63-
fancyMessageBox.showMessage(message, title);
64-
}
65-
public static void mock(FancyMessageBoxInstance messageBoxMock)
66-
{
67-
fancyMessageBox = messageBoxMock;
58+
fancyMessageBox.showMessage(message, title, icon);
6859
}
6960
public static class FancyMessageBoxInstance
7061
{
62+
public static void mock(FancyMessageBoxInstance messageBoxMock)
63+
{
64+
fancyMessageBox = messageBoxMock;
65+
}
7166
public int askForNumericalInput(String message, String title)
7267
{
7368
String input = askForTextInput(message, title);
@@ -77,9 +72,9 @@ public String askForTextInput(String message, String title)
7772
{
7873
return JOptionPane.showInputDialog(null, message, title, -1);
7974
}
80-
public void showMessage(String message, String title)
75+
public void showMessage(String message, String title, ImageIcon icon)
8176
{
82-
JOptionPane.showMessageDialog(null, message, title, -1);
77+
JOptionPane.showMessageDialog(null, message, title, -1, icon);
8378
}
8479
}
8580
}

src/main/java/org/teachingextensions/logo/utils/EventUtils/MessageBox.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
* <img src=
99
* "http://www.mhhe.com/engcs/compsci/wu2/graphics/wu2java/common/javabook2Doc/mbox3.gif"
1010
* style="text-align: left" alt="A message box" height="60" width="145"> <br>
11-
* <br>
12-
* <br>
13-
* <br>
14-
* <br>
15-
* MessageBox is a pop up window<br>
16-
* Use it to collect numerical input from the user<br>
17-
* Or to display a message for the user to read.<br>
11+
* MessageBox is a pop up window. Use it to collect input from the user, or to display a message for the user to read.<br>
1812
*/
1913
public class MessageBox
2014
{

src/main/java/org/teachingkidsprogramming/recipes/completed/section06modelviewcontroller/OneFishTwoFish.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.Iterator;
44
import java.util.Scanner;
55

6+
import javax.swing.ImageIcon;
7+
68
import org.teachingextensions.logo.utils.EventUtils.FancyMessageBox;
79

810
//*************This Lesson is In Development*****************************//
@@ -44,22 +46,24 @@ public Iterator<String> iterator()
4446
}
4547
public static void makeAFishyDecision(int numberOfFish)
4648
{
49+
String image = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//thumb-up.png";
50+
final ImageIcon icon = new ImageIcon(image);
4751
switch (numberOfFish)
4852
{
4953
case -1 :
50-
FancyMessageBox.showMesage("Had a Fish", "Not hungry anymore...");
54+
FancyMessageBox.showMesage("Had a Fish", "Not hungry anymore...", icon);
5155
break;
5256
case 0 :
53-
FancyMessageBox.showMesage("No Fish", "None");
57+
FancyMessageBox.showMesage("No Fish", "None", icon);
5458
break;
5559
case 1 :
56-
FancyMessageBox.showMesage("One Fish", "One");
60+
FancyMessageBox.showMesage("One Fish", "One", icon);
5761
break;
5862
case 2 :
59-
FancyMessageBox.showMesage("Two Fish", "Two");
63+
FancyMessageBox.showMesage("Two Fish", "Two", icon);
6064
break;
6165
default :
62-
FancyMessageBox.showMesage("Vegetaraian meal", "Fish are icky");
66+
FancyMessageBox.showMesage("Vegetaraian meal", "Fish are icky", icon);
6367
break;
6468
}
6569
}

src/main/resources/icons/add.png

770 Bytes
Loading
17.6 KB
Loading

src/main/resources/icons/check.png

813 Bytes
Loading
12.3 KB
Loading
5.78 KB
Loading
17.9 KB
Loading

src/main/resources/icons/hint.png

1.34 KB
Loading

0 commit comments

Comments
 (0)