Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void startJamJButtonActionPerformed(java.awt.event.ActionEvent evt) {
- if (startJamJButton.getText().equalsIgnoreCase("Start Jam")) {
- jamTimeJTextField.setText("Jam #" + jamNum + " 2:00");
- startJamJButton.setText("End Jam");
- doWork_startJam = true;
- } else if (startJamJButton.getText().equalsIgnoreCase("End Jam")) {
- startJamJButton.setText("Start Jam");
- firstTime_startJam = false;
- jamTimeJTextField.setText("Jam #" + jamNum + " 0:30");
- }
- ActionListener taskPerformer = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (!doWork_startJam) {
- return;
- }
- String initial = jamTimeJTextField.getText();
- String[] time = initial.split(":"); // 2:00
- initial = initial.substring(0, initial.length() - 4);
- int min = Integer.parseInt(time[0].substring(time[0].length() - 1)); // Jam # 2
- int sec = Integer.parseInt(time[1]);
- if (sec == 00) {
- min--;
- sec = 59;
- } else {
- sec--;
- }
- if (sec < 10) {
- jamTimeJTextField.setText(initial + min + ":0" + sec);
- } else {
- jamTimeJTextField.setText(initial + min + ":" + sec);
- }
- if (min == 0 && sec == 0) {
- jamNum++;
- firstTime_startJam = false;
- doWork_startJam = false;
- startJamJButton.setText("Start Jam");
- }
- }
- };
- Timer jamTimer = new Timer(startJamSpeed, taskPerformer);
- if (firstTime_startJam) {
- jamTimer.start();
- }
- }
- private void startJButtonActionPerformed(java.awt.event.ActionEvent evt) {
- if (startJButton.getText().equalsIgnoreCase("Start")) {
- if (timerJTextField.getText().equals("0:00"))
- timerJTextField.setText("20:00");
- startJButton.setText("Pause");
- doWork_start = true;
- } else if (startJButton.getText().equalsIgnoreCase("Pause")) {
- startJButton.setText("Start");
- firstTime_start = false;
- doWork_start = false;
- }
- ActionListener taskPerformer = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (!doWork_start) {
- return;
- }
- String initial = timerJTextField.getText();
- String[] time = initial.split(":"); // 20:00
- int min = Integer.parseInt(time[0]); // 20
- int sec = Integer.parseInt(time[1]); // 00
- if (sec == 00) {
- min--;
- sec = 59;
- } else {
- sec--;
- }
- if (sec < 10) {
- timerJTextField.setText(min + ":0" + sec);
- } else {
- timerJTextField.setText(min + ":" + sec);
- }
- if (min == 0 && sec == 0) {
- firstTime_start = false;
- doWork_start = false;
- startJButton.setText("Start");
- }
- }
- };
- Timer startTimer = new Timer(startSpeed, taskPerformer);
- if (firstTime_start) {
- startTimer.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement