diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-05-07 12:51:23 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-05-07 12:51:23 -0400 |
| commit | 87ae1dfc8d8cb7b51d7bda4750ce841bbe691cfc (patch) | |
| tree | 290f31282898bd39300c70646c6fe2b65832886a /BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java | |
| parent | fb7d03388e298258563c22abda1bd46cdaf991b7 (diff) | |
General changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java b/BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java index 4cbfb61..49c7283 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gui/HolderOutputPanel.java @@ -17,25 +17,31 @@ public class HolderOutputPanel extends JPanel { private static final long serialVersionUID = 166573313903782080L; private Timer updateTimer; private JLabel value; + private int nDelay; + private IHolder<String> val; /** * Create a new display panel, backed by a holder * * @param lab * The label to attach to this field - * @param val + * @param valueHolder * The holder to get the value from * @param nDelay * The delay in ms between value updates */ - public HolderOutputPanel(String lab, IHolder<String> val, int nDelay) { + public HolderOutputPanel(String lab, IHolder<String> valueHolder, + int nDelay) { + this.val = valueHolder; + this.nDelay = nDelay; + setLayout(new HLayout(2)); JLabel label = new JLabel(lab); - value = new JLabel(val.getValue() + " (stopped)"); + value = new JLabel("(stopped)"); updateTimer = new Timer(nDelay, (event) -> { - value.setText(val.getValue()); + value.setText(valueHolder.getValue()); }); add(label); @@ -57,4 +63,17 @@ public class HolderOutputPanel extends JPanel { value.setText(value.getText() + " (stopped)"); } + + /** + * Set this panel back to its initial state + */ + public void reset() { + stopUpdating(); + + value.setText("(stopped)"); + + updateTimer = new Timer(nDelay, (event) -> { + value.setText(val.getValue()); + }); + } } |
