Java Reference
In-Depth Information
L ISTING 12.7
Continued
matchButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
// the “match” button has been pushed
Versionable v1 = Versionable.createVersionId
(versionIdTextField.getText());
versionIdTextField.setText(v1.toString());
Versionable v2 = Versionable.createVersionable
(versionStringTextField.getText());
versionStringTextField.setText(v2.toString());
outcomeLabel.setText(“ result: “ + v1.match(v2)+” “);
}
});
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
getContentPane().add(jPanel2, null);
jPanel1.add(jLabel1, null);
jPanel1.add(versionStringTextField, null);
getContentPane().add(jPanel3, null);
jPanel3.add(matchButton, null);
getContentPane().add(jPanel1, null);
jPanel2.add(jLabel2, null);
jPanel2.add(versionIdTextField, null);
outcomeLabel.setBorder(BorderFactory.createEtchedBorder());
outcomeLabel.setText(“comparison result”);
getContentPane().add(outcomeLabel, null);
setSize(224,192);
setTitle(“Version Strings Test”);
setVisible(true);
}
/**
* launch this class to start the GUI interactive version testing
*/
public static void main(String[] args) {
Test test1 = new Test();
}
}
Search WWH ::




Custom Search