lphystudio.core.valueeditor.StringValueEditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lphy-studio Show documentation
Show all versions of lphy-studio Show documentation
The GUI for LPhy language.
The newest version!
package lphystudio.core.valueeditor;
import lphy.core.model.Value;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class StringValueEditor extends JTextField {
private Value value;
public StringValueEditor(Value value) {
this.value = value;
setText(value.value());
setColumns(20);
getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
setValue(getText());
}
@Override
public void removeUpdate(DocumentEvent e) {
setValue(getText());
}
@Override
public void changedUpdate(DocumentEvent e) {
setValue(getText());
}
void setValue(String text) {
value.setValue(text);
}
});
}
}