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.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
@ -32,6 +33,16 @@ public class AnalogClock extends JPanel {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
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
|
||||
|
@ -9,6 +9,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ProgressSquare extends JPanel {
|
||||
|
||||
@ -22,6 +23,16 @@ public class ProgressSquare extends JPanel {
|
||||
|
||||
public void setHighlight(boolean 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() {
|
||||
@ -32,6 +43,16 @@ public class ProgressSquare extends JPanel {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
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
|
||||
|
@ -116,6 +116,11 @@ public class TimeCalcWindow {
|
||||
.setBounds(10 + analogClock.getWidth() + 10, 10, 200, 200);
|
||||
window.add(progressSquare);
|
||||
|
||||
|
||||
if(Utils.highlightTxt.exists()) {
|
||||
analogClock.setHighlight(true);
|
||||
progressSquare.setHighlight(true);
|
||||
}
|
||||
StringBuilder sb = null;
|
||||
while (true) {
|
||||
if (stopBeforeEnd) {
|
||||
@ -226,6 +231,10 @@ public class TimeCalcWindow {
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
|
||||
boolean exists = Utils.highlightTxt.exists();
|
||||
analogClock.setHighlight(exists);
|
||||
progressSquare.setHighlight(exists);
|
||||
}
|
||||
window.setVisible(false);
|
||||
window.dispose();
|
||||
|
@ -20,7 +20,7 @@ public class Utils {
|
||||
* Count of bytes per one kilobyte.
|
||||
*/
|
||||
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.
|
||||
* @param file file
|
||||
|
Loading…
x
Reference in New Issue
Block a user