Added new improvements

This commit is contained in:
Robert Vokac 2024-02-10 15:53:39 +00:00
parent f624f828c9
commit c07588ec73
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
2 changed files with 31 additions and 18 deletions

View File

@ -49,7 +49,7 @@ import java.util.logging.Logger;
public class TimeCalcManager { public class TimeCalcManager {
public static final Color BG = new Color(238, 238, 238); public static final Color BG = new Color(238, 238, 238);
public static final Color FG = new Color(210, 210, 210); public static final Color FG = new Color(210, 210, 210);
private static final int MARGIN = 10; public static final int MARGIN = 10;
private final String windowTitle; private final String windowTitle;
private final int totalMinutes; private final int totalMinutes;
@ -90,6 +90,7 @@ public class TimeCalcManager {
TimeCalcWindow window = new TimeCalcWindow(); TimeCalcWindow window = new TimeCalcWindow();
TimeCalcButton configButton = new TimeCalcButton("Config");
TimeCalcButton commandButton = new TimeCalcButton("Command"); TimeCalcButton commandButton = new TimeCalcButton("Command");
TimeCalcButton weatherButton = new TimeCalcButton("Weather"); TimeCalcButton weatherButton = new TimeCalcButton("Weather");
TimeCalcButton jokeButton = new TimeCalcButton("Joke"); TimeCalcButton jokeButton = new TimeCalcButton("Joke");
@ -98,7 +99,7 @@ public class TimeCalcManager {
AboutButton aboutButton = new AboutButton(); AboutButton aboutButton = new AboutButton();
//window.add(weatherButton); //window.add(weatherButton);
window.addAll(commandButton, jokeButton, restartButton, window.addAll(configButton, commandButton, jokeButton, restartButton,
exitButton); exitButton);
window.addKeyListener(new KeyAdapter() { window.addKeyListener(new KeyAdapter() {
// Key Pressed method // Key Pressed method
@ -185,23 +186,15 @@ public class TimeCalcManager {
window.add(walkingHumanProgressAsciiArt); window.add(walkingHumanProgressAsciiArt);
weatherButton weatherButton
.setBounds(20, walkingHumanProgressAsciiArt.getY() .setBounds(MARGIN, walkingHumanProgressAsciiArt.getY()
+ walkingHumanProgressAsciiArt.getHeight() + walkingHumanProgressAsciiArt.getHeight()
+ MARGIN); + MARGIN);
commandButton.setBounds(20, walkingHumanProgressAsciiArt.getY() configButton.setBoundsFromTop(walkingHumanProgressAsciiArt);
+ walkingHumanProgressAsciiArt.getHeight() commandButton.setBoundsFromLeft(configButton);
+ MARGIN);
jokeButton.setBounds(140, walkingHumanProgressAsciiArt.getY() jokeButton.setBoundsFromLeft(commandButton);
+ walkingHumanProgressAsciiArt.getHeight() restartButton.setBoundsFromLeft(jokeButton);
+ MARGIN); exitButton.setBoundsFromLeft(restartButton);
restartButton
.setBounds(280, walkingHumanProgressAsciiArt.getY()
+ walkingHumanProgressAsciiArt.getHeight()
+ MARGIN);
exitButton.setBounds(390, walkingHumanProgressAsciiArt.getY()
+ walkingHumanProgressAsciiArt.getHeight()
+ MARGIN);
aboutButton.setBounds(exitButton.getX(), aboutButton.setBounds(exitButton.getX(),
exitButton.getY() + exitButton.getHeight() + MARGIN); exitButton.getY() + exitButton.getHeight() + MARGIN);
@ -478,6 +471,7 @@ public class TimeCalcManager {
weekBattery, weekBattery,
monthBattery, monthBattery,
hourBattery, hourBattery,
configButton,
jokeButton, jokeButton,
commandButton, commandButton,
restartButton, restartButton,
@ -494,11 +488,15 @@ public class TimeCalcManager {
weekBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); weekBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
monthBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); monthBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
hourBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); hourBattery.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
configButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
jokeButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); jokeButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
commandButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); commandButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
restartButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); restartButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
exitButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty); exitButton.visibilityProperty.bindTo(timeCalcApp.visibilityProperty);
configButton.setVisible(
!Visibility.valueOf(configButton.visibilityProperty.getValue())
.isNone());
jokeButton.setVisible( jokeButton.setVisible(
!Visibility.valueOf(jokeButton.visibilityProperty.getValue()) !Visibility.valueOf(jokeButton.visibilityProperty.getValue())
.isNone()); .isNone());
@ -535,21 +533,25 @@ public class TimeCalcManager {
.valueOf(timeCalcApp.visibilityProperty.getValue()); .valueOf(timeCalcApp.visibilityProperty.getValue());
componentRegistry.setVisible(visibility.isNotNone()); componentRegistry.setVisible(visibility.isNotNone());
if (!visibility.isStronglyColored() || visibility.isGray()) { if (!visibility.isStronglyColored() || visibility.isGray()) {
configButton.setBackground(BG);
jokeButton.setBackground(BG); jokeButton.setBackground(BG);
commandButton.setBackground(BG); commandButton.setBackground(BG);
restartButton.setBackground(BG); restartButton.setBackground(BG);
exitButton.setBackground(BG); exitButton.setBackground(BG);
configButton.setForeground(FG);
jokeButton.setForeground(FG); jokeButton.setForeground(FG);
commandButton.setForeground(FG); commandButton.setForeground(FG);
restartButton.setForeground(FG); restartButton.setForeground(FG);
exitButton.setForeground(FG); exitButton.setForeground(FG);
} else { } else {
configButton.setOriginalBackground();
jokeButton.setOriginalBackground(); jokeButton.setOriginalBackground();
commandButton.setOriginalBackground(); commandButton.setOriginalBackground();
restartButton.setOriginalBackground(); restartButton.setOriginalBackground();
exitButton.setOriginalBackground(); exitButton.setOriginalBackground();
// //
configButton.setOriginalForeground();
jokeButton.setOriginalForeground(); jokeButton.setOriginalForeground();
commandButton.setOriginalForeground(); commandButton.setOriginalForeground();
restartButton.setOriginalForeground(); restartButton.setOriginalForeground();

View File

@ -1,9 +1,11 @@
package org.nanoboot.utils.timecalc.swing.common; package org.nanoboot.utils.timecalc.swing.common;
import org.nanoboot.utils.timecalc.app.TimeCalcManager;
import org.nanoboot.utils.timecalc.entity.Visibility; import org.nanoboot.utils.timecalc.entity.Visibility;
import org.nanoboot.utils.timecalc.utils.property.StringProperty; import org.nanoboot.utils.timecalc.utils.property.StringProperty;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.Timer; import javax.swing.Timer;
import java.awt.Color; import java.awt.Color;
@ -38,4 +40,13 @@ public class TimeCalcButton extends JButton {
public void setOriginalForeground() { public void setOriginalForeground() {
this.setForeground(originalForeground); this.setForeground(originalForeground);
} }
public void setBoundsFromLeft(JComponent jComponent) {
setBounds(jComponent.getX() + jComponent.getWidth() + TimeCalcManager.MARGIN, jComponent.getY());
}
public void setBoundsFromTop(JComponent jComponent) {
setBounds(TimeCalcManager.MARGIN, jComponent.getY()
+ jComponent.getHeight()
+ TimeCalcManager.MARGIN);
}
} }