ExamInfopublic 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. |
Fields Summary |
---|
TD | theTDThe Data Model | Exam | theExamThe Exam part of it. | JTextField | cTitleTextfield for the Course Title | JTextField | cNumTextfield for the Course Number | JTextField | xNumTextfield for the Exam Number | JTextField | xVersTextfield for the Course Version# | JTextField | oLabelTextfield for the "Objectives" label | JTextField | numQuestionsTextfield 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 Idiots 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 void | main(java.lang.String[] a)
Frame frm = new Frame("Testing ExamInfo");
frm.add(new ExamInfo());
frm.pack();
frm.setVisible(true);
| protected void | setValues()Whenever Apply is pushed, store the information back to the model.
theExam.setCourseTitle(cTitle.getText());
theExam.setCourseNumber(cNum.getText());
// XXX
| public void | setVisible(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);
|
|