BreezyGUI
package during the labs. You should also
have the directory on the CD that comes with the book.
We have posted a tutorial on using
Symantec Cafe with the BreezyGUI
package. The only
requirement is that the BreezyGUI
directory be in
the same directory with the project that you are developing. The
tutorial builds a project for the program discussed on page 37 in
your textbook.
During this lab you will build a few standalone applications that have
a graphical user interface (using the BreezyGUI
package).
At the end of this lab you should be in very good shape to start working
on your assignments.
1. A simple Tester program (Tester.java
)
2. A simple Counter program (import java.awt.*; import BreezyGUI.*; public class Tester extends GBFrame { public static void main(String[] args) { System.out.println("This is a test."); GBFrame.pause(); } }
Counter.java
)3. An Add/Subtract program (import java.awt.*; import BreezyGUI.*; public class Counter extends GBFrame { Label result = addLabel ("Counter starts at 0 " , 1, 1, 1, 1); Button action = addButton("Add 1", 2, 1, 1, 1); int counter; // this variable is visible to buttonClicked public void buttonClicked (Button buttonObj) { counter = counter + 1; result.setText("Counter is now: " + counter); } public static void main(String[] args) { Frame f = new Counter(); f.setSize(200, 100); f.setVisible(true); } }
NewCounter.java
) In this program you use two buttons.
4. A simple Echo program (withimport java.awt.*; import BreezyGUI.*; public class NewCounter extends GBFrame { Label result = addLabel ("Counter starts at 0 " , 1, 1, 2, 1); Button aButton = addButton("Add 1", 2, 1, 1, 1); Button sButton = addButton("Sub 1", 2, 2, 1, 1); int counter; // this variable is visible to buttonClicked public void buttonClicked (Button buttonObj) { if (buttonObj == aButton) { counter = counter + 1; result.setText("Counter is now: " + counter); } else { counter = counter - 1; result.setText("Counter is now: " + counter); } } public static void main(String[] args) { Frame f = new NewCounter(); f.setSize(200, 100); f.setVisible(true); } }
messageBox
es)
5. Putting it all together (to some extent)import java.awt.*; import BreezyGUI.*; public class Echo extends GBFrame { Label msgLabel = addLabel ("Input:", 1, 1, 1, 1); TextField msgField = addTextField ("" , 1, 2, 1, 1); Button postButton = addButton ("Post" , 2, 1, 2, 1); public void buttonClicked (Button b) { messageBox(msgField.getText()); } public static void main(String[] args) { Frame x = new Echo(); x.setSize(100, 100); x.setVisible(true); } }
import java.awt.*; import BreezyGUI.*; public class Five extends GBFrame { Label a = addLabel ("Name: ", 1, 1, 1, 1); TextField b = addTextField ("" , 1, 2, 1, 1); Label c = addLabel ("Age" , 2, 1, 1, 1); IntegerField d = addIntegerField ( 0 , 2, 2, 1, 1); Button e = addButton ("Report", 3, 1, 2, 1); public void buttonClicked (Button buttonObj) { messageBox ( b.getText() + " is " + d.getNumber() + " years old." ); } public static void main(String[] args) { Frame f = new Five(); f.setSize(200, 100); f.setVisible(true); } }