FileDocCategorySizeDatePackage
TestRegexConstrainedDocument.javaAPI DocExample1447Mon Jan 09 11:02:00 GMT 2006None

TestRegexConstrainedDocument

public class TestRegexConstrainedDocument extends JPanel implements ActionListener

Fields Summary
JTextField
regexField
JTextField
filterField
JButton
regexButton
RegexConstrainedDocument
regexDoc
Constructors Summary
public TestRegexConstrainedDocument()

        setLayout (new BoxLayout (this, BoxLayout.Y_AXIS));
        // top - regex stuff
        JPanel topPanel = new JPanel();
        JLabel rLabel = new JLabel ("regex:" );
        topPanel.add (rLabel);
        regexField = new JTextField (20);
        topPanel.add(regexField);
        regexButton = new JButton ("Set");
        regexButton.addActionListener (this);
        topPanel.add (regexButton);
        add (topPanel);
        // bottom - filterfield
        regexDoc =
            new RegexConstrainedDocument ();
        filterField = new JTextField (regexDoc, "",  50);
        add (filterField);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        System.out.println ("actionperformed");
        if (e.getSource() == regexButton) {
            System.out.println ("regexbutton");
            regexDoc.setPatternByString (regexField.getText());
        }
    
public static voidmain(java.lang.String[] args)

        JComponent c = new TestRegexConstrainedDocument();
        JFrame f = new JFrame ("Regex filtering");
        f.getContentPane().add (c);
        f.pack();
        f.setVisible(true);