Construct the REDemo object including its GUI
super();
JPanel top = new JPanel();
top.add(new JLabel("Pattern:", JLabel.RIGHT));
patternTF = new JTextField(20);
patternTF.getDocument().addDocumentListener(new PatternListener());
top.add(patternTF);
top.add(new JLabel("Syntax OK?"));
compiledOK = new JCheckBox();
top.add(compiledOK);
ChangeListener cl = new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
tryMatch();
}
};
JPanel switchPane = new JPanel();
ButtonGroup bg = new ButtonGroup();
match = new JRadioButton("Match");
match.setSelected(true);
match.addChangeListener(cl);
bg.add(match);
switchPane.add(match);
find = new JRadioButton("Find");
find.addChangeListener(cl);
bg.add(find);
switchPane.add(find);
findAll = new JRadioButton("Find All");
findAll.addChangeListener(cl);
bg.add(findAll);
switchPane.add(findAll);
JPanel strPane = new JPanel();
strPane.add(new JLabel("String:", JLabel.RIGHT));
stringTF = new JTextField(20);
stringTF.getDocument().addDocumentListener(new StringListener());
strPane.add(stringTF);
strPane.add(new JLabel("Matches:"));
matchesTF = new JTextField(3);
strPane.add(matchesTF);
setLayout(new GridLayout(0, 1, 5, 5));
add(top);
add(strPane);
add(switchPane);