Example usage for java.awt TextField validate

List of usage examples for java.awt TextField validate

Introduction

In this page you can find the example usage for java.awt TextField validate.

Prototype

public void validate() 

Source Link

Document

Validates this component.

Usage

From source file:vincent.DynamicDataDemo.java

/**
 * Constructs a new demonstration application.
 * //  w  w w. j a  v a  2 s  .c  om
 * @param title the frame title.
 */
public DynamicDataDemo(final String title) {

    super(title);
    this.series = new TimeSeries("Random Data");
    final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series);
    final JFreeChart chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPanel content = new JPanel(new BorderLayout());
    content.add(chartPanel);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    setContentPane(content);

    // Zone de saisie de commande vers le port srie :
    TextField zoneSaisie = new TextField(10);
    chartPanel.add(zoneSaisie);
    zoneSaisie.setLocation(100, 300);
    zoneSaisie.validate();
    zoneSaisie.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                TextField textField = (TextField) e.getComponent();

                try {
                    BufferedWriter writer = tempSerialReader.getEcrivainPortSerie();
                    writer.write(textField.getText());
                    writer.write('\r');
                    writer.flush();
                } catch (IOException l_ex) {
                    LOG.error("erreur d'criture sur le port srie: ", l_ex);
                }
            }
        }
    });

    temperatureCouranteLabel = new Label("XX.XC");
    chartPanel.add(temperatureCouranteLabel);
    chartPanel.add(tempsDeChauffeEtRelicat);
    chartPanel.add(paramsPid);

    tempSerialReader = new TempSerialReader(this);
}