FileDocCategorySizeDatePackage
ExamInfo.javaAPI DocExample3304Sun Feb 08 21:34:00 GMT 2004None

ExamInfo

public class ExamInfo extends JPanel
Pane for editing the Exam info. Instead of a full MVC paradigm, we re-fetch the information whenever setVisible(true) is done, and store the information whenever our Apply button is pushed.
author
Ian F. Darwin, http://www.darwinsys.com/

Fields Summary
TD
theTD
The Data Model
Exam
theExam
The Exam part of it.
JTextField
cTitle
Textfield for the Course Title
JTextField
cNum
Textfield for the Course Number
JTextField
xNum
Textfield for the Exam Number
JTextField
xVers
Textfield for the Course Version#
JTextField
oLabel
Textfield for the "Objectives" label
JTextField
numQuestions
Textfield for the Number of Questions
Constructors Summary
public ExamInfo(TD m)
Construct an ExamInfo Dialog with a TD model

		// super("Exam Info");
		theTD = m;
		theExam = m.curX;

		// Container cp = getContentPane();	// in a Frame
		Container cp = this;				// in a Panel
		cp.setLayout(new GridLayout(0,2));

		cp.add(new JLabel("Course Title", JLabel.RIGHT));
		cp.add(cTitle = new JTextField("Coffee programming for Newbies Hands-On"));

		cp.add(new JLabel("Course Number", JLabel.RIGHT));
		cp.add(cNum = new JTextField("471"));
		cNum.setToolTipText("Number of this course");

		cp.add(new JLabel("Exam Number", JLabel.RIGHT));
		cp.add(xNum = new JTextField("A"));
		xNum.setToolTipText("Exam (A, B, or C)");

		cp.add(new JLabel("Exam Revision", JLabel.RIGHT));
		cp.add(xVers = new JTextField("D.1"));
		xVers.setToolTipText("Exam Version (A.1, ...)");

		cp.add(new JLabel("Objectives Label", JLabel.RIGHT));
		cp.add(oLabel = new JTextField(""));
		oLabel.setToolTipText("Chapter, Page, or Section reference");

		cp.add(new JLabel("Number of questions", JLabel.RIGHT));
		cp.add(numQuestions = new JTextField("99"));
		numQuestions.setToolTipText("Number of questions in this Exam");

		JButton b;
		cp.add(b = new JButton("Apply"));
		b.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ce) {
				if (theTD == null)
					System.out.println("Changes would be applied");
				else {
					setValues();
				}
				// setVisible(false);
				// dispose();
			}
		});
		cp.add(b = new JButton("Cancel"));
		b.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ce) {
				System.out.println("No changes applied");
				// setVisible(false);
				// dispose();
			}
		});
		// pack();
	
public ExamInfo()
Construct an ExamInfo Dialog with NO TD model

		this(null);
	
Methods Summary
public static voidmain(java.lang.String[] a)

		Frame frm = new Frame("Testing ExamInfo");
		frm.add(new ExamInfo());
		frm.pack();
		frm.setVisible(true);
	
protected voidsetValues()
Whenever Apply is pushed, store the information back to the model.

		theExam.setCourseTitle(cTitle.getText());
		theExam.setCourseNumber(cNum.getText());
		// XXX
	
public voidsetVisible(boolean vis)
Whenever we're displayed, update the information

		if (vis && theTD!=null) {
			cTitle.setText(theExam.getCourseTitle());
			cNum.setText(theExam.getCourseNumber());
			// XXX
		}
		// super.setVisible(vis);