Added sqlite support - wip 5

This commit is contained in:
Robert Vokac 2024-03-09 13:00:54 +00:00
parent d28b92915e
commit 119bba1578
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
2 changed files with 16 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgress;
import org.nanoboot.utils.timecalc.swing.progress.WeekBattery;
import org.nanoboot.utils.timecalc.swing.progress.YearBattery;
import org.nanoboot.utils.timecalc.utils.common.Constants;
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
import org.nanoboot.utils.timecalc.utils.common.Jokes;
import org.nanoboot.utils.timecalc.utils.common.TTime;
import org.nanoboot.utils.timecalc.utils.common.Utils;
@ -31,6 +32,7 @@ import java.awt.Color;
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.io.File;
/**
* @author Robert Vokac
@ -256,6 +258,8 @@ public class MainWindow extends TWindow {
remainingTextField.setBoundsFromLeft(remainingTextFieldLabel);
remainingTextField.setEditable(false);
TButton saveButton = new TButton("Save", 80);
saveButton.setBoundsFromLeft(remainingTextField);
//
add(departureTextFieldLabel);
@ -264,6 +268,12 @@ public class MainWindow extends TWindow {
add(elapsedTextField);
add(remainingTextFieldLabel);
add(remainingTextField);
add(saveButton);
saveButton.addActionListener(e -> {
TTime overtime_ =overtimeTextField.asTimeHM();
Utils.writeTextToFile(FileConstants.STARTTIME_TXT, arrivalTextField.asTimeHM().toString().substring(0,5));
Utils.writeTextToFile(FileConstants.OVERTIME_TXT, overtime_.toString().substring(0,overtime_.isNegative() ? 6 : 5));
});
//
configButton.setBoundsFromTop(departureTextFieldLabel);
workDaysButton.setBoundsFromLeft(configButton);

View File

@ -28,9 +28,14 @@ public class TButton extends JButton implements GetProperty {
Visibility.STRONGLY_COLORED.name());
private Color originalBackground;
private Color originalForeground;
private int customWidth = 0;
public TButton(String label) {
this(label, 0);
}
public TButton(String label, int customWidth) {
super(label);
this.customWidth = customWidth;
new Timer(100, e -> {
if (!MainWindow.hideShowFormsCheckBox.isSelected()) {
setVisible(false);
@ -52,7 +57,7 @@ public class TButton extends JButton implements GetProperty {
}
public void setBounds(int x, int y) {
setBounds(x, y, BUTTON_WIDTH, BUTTON_HEIGHT);
setBounds(x, y, customWidth == 0 ? BUTTON_WIDTH : customWidth, BUTTON_HEIGHT);
this.originalBackground = getBackground();
this.originalForeground = getForeground();
}