1 package org.woehlke.computer.kurzweil.commons.widgets;
2
3 import lombok.Getter;
4 import lombok.ToString;
5 import lombok.extern.log4j.Log4j2;
6 import org.woehlke.computer.kurzweil.commons.Startable;
7 import org.woehlke.computer.kurzweil.tabs.Tab;
8
9 import javax.swing.*;
10
11 @Log4j2
12 @ToString(exclude={"startButton","stopButton"})
13 public class PanelStartStopButtons extends SubTabImpl implements Startable, SubTab {
14
15 private final String labelStart;
16 private final String labelStop;
17 @Getter
18 private final JButton startButton;
19 @Getter
20 private final JButton stopButton;
21
22 public PanelStartStopButtons(Tab tab){
23 super(tab.getCtx().getProperties().getAllinone().getView().getStartStopp(),tab.getCtx().getProperties());
24 labelStart = tab.getCtx().getProperties().getAllinone().getView().getStart();
25 labelStop = tab.getCtx().getProperties().getAllinone().getView().getStop();
26 this.startButton = new JButton(labelStart);
27 this.stopButton = new JButton(labelStop);
28 this.startButton.setEnabled(true);
29 this.stopButton.setEnabled(false);
30 this.add(this.startButton);
31 this.add(this.stopButton);
32 this.startButton.addActionListener(tab);
33 this.stopButton.addActionListener(tab);
34 }
35
36 @Override
37 public void start() {
38 log.info("start");
39 this.startButton.setEnabled(false);
40 this.stopButton.setEnabled(true);
41 log.info("started");
42 }
43
44 @Override
45 public void stop() {
46 log.info("stop");
47 this.startButton.setEnabled(true);
48 this.stopButton.setEnabled(false);
49 log.info("stopped");
50 }
51
52 }