mirror of
https://github.com/robertvokac/time-calc.git
synced 2025-03-25 07:27:49 +01:00
New improvements
This commit is contained in:
parent
0abf40fded
commit
ec2ed16cac
0
highlight.txt
Normal file
0
highlight.txt
Normal file
@ -12,6 +12,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
@ -32,6 +33,16 @@ public class AnalogClock extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
highlight = !highlight;
|
highlight = !highlight;
|
||||||
|
if(highlight && !Utils.highlightTxt.exists()) {
|
||||||
|
try {
|
||||||
|
Utils.highlightTxt.createNewFile();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!highlight && Utils.highlightTxt.exists()) {
|
||||||
|
Utils.highlightTxt.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,6 +9,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ProgressSquare extends JPanel {
|
public class ProgressSquare extends JPanel {
|
||||||
|
|
||||||
@ -22,6 +23,16 @@ public class ProgressSquare extends JPanel {
|
|||||||
|
|
||||||
public void setHighlight(boolean highlight) {
|
public void setHighlight(boolean highlight) {
|
||||||
this.highlight = highlight;
|
this.highlight = highlight;
|
||||||
|
if(highlight && !Utils.highlightTxt.exists()) {
|
||||||
|
try {
|
||||||
|
Utils.highlightTxt.createNewFile();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
System.out.println(ioException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!highlight && Utils.highlightTxt.exists()) {
|
||||||
|
Utils.highlightTxt.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressSquare() {
|
public ProgressSquare() {
|
||||||
@ -32,6 +43,16 @@ public class ProgressSquare extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
highlight = !highlight;
|
highlight = !highlight;
|
||||||
|
if(highlight && !Utils.highlightTxt.exists()) {
|
||||||
|
try {
|
||||||
|
Utils.highlightTxt.createNewFile();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!highlight && Utils.highlightTxt.exists()) {
|
||||||
|
Utils.highlightTxt.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,6 +116,11 @@ public class TimeCalcWindow {
|
|||||||
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
||||||
window.add(progressSquare);
|
window.add(progressSquare);
|
||||||
|
|
||||||
|
|
||||||
|
if(Utils.highlightTxt.exists()) {
|
||||||
|
analogClock.setHighlight(true);
|
||||||
|
progressSquare.setHighlight(true);
|
||||||
|
}
|
||||||
StringBuilder sb = null;
|
StringBuilder sb = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (stopBeforeEnd) {
|
if (stopBeforeEnd) {
|
||||||
@ -226,6 +231,10 @@ public class TimeCalcWindow {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean exists = Utils.highlightTxt.exists();
|
||||||
|
analogClock.setHighlight(exists);
|
||||||
|
progressSquare.setHighlight(exists);
|
||||||
}
|
}
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
window.dispose();
|
window.dispose();
|
||||||
|
@ -20,7 +20,7 @@ public class Utils {
|
|||||||
* Count of bytes per one kilobyte.
|
* Count of bytes per one kilobyte.
|
||||||
*/
|
*/
|
||||||
private static final int COUNT_OF_BYTES_PER_ONE_KILOBYTE = 1024;
|
private static final int COUNT_OF_BYTES_PER_ONE_KILOBYTE = 1024;
|
||||||
|
public static final File highlightTxt = new File("highlight.txt");
|
||||||
/**
|
/**
|
||||||
* Writes text to a file.
|
* Writes text to a file.
|
||||||
* @param file file
|
* @param file file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user