Page 366 - Introduction to Programming with Java: A Problem Solving Approach
P. 366
332 Chapter 8 Software Engineering
/******************************************************************
*
CRCCard.java
Dean & Dean
This program creates a GUI display of CRC cards.
******************************************************************/
*
*
*
import java.util.Scanner;
import javax.swing.*; // for JFrame, JTextArea, & JSplitFrame
public class CRCCard
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
String input;
System.out.print("Enter class name or 'q' to quit: ");
input = stdIn.nextLine();
while (!input.equalsIgnoreCase("q"))
{
JFrame frame = new JFrame("Class: " + input);
JTextArea responsibilities = ⎫
new JTextAreAa(p"RaESgPOoNSIBPILDIFTIESE:\n"h);a⎪ncer
JTextArea collaborators = ⎬ Createtwocontainers. ⎪
new JTextArea("COLLABORATORS:\n"); ⎭ JSplitPane splitPane = ⎫ new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,⎬ responsibilities, collaborators); ⎭
frame.setSize(350, 210);
frame.add(splitPane);
frame.setLocationByPlatform(true);
frame.setVisible(true);
frame.toFront();
splitPane.setDividerLocation(0.67);
Put split pane in window.
}
// end class CRCCard
}
// end main
}
System.out.print("Enter class name or 'q' to quit: ");
input = stdIn.nextLine();
// end while
Create a new window.
Put containers into split panes.
Figure 8.13 Program that puts interactive CRC cards on your computer screen