#fix 19 TabPohja on nyt Tab, joka hoitaa monia asioita kuin itsestään

Signed-off-by: laurimaaninka <lauri.maaninka@gmail.com>
This commit is contained in:
2026-05-14 23:24:22 +03:00
parent 1b589d0fb5
commit 342f62dedd
11 changed files with 175 additions and 163 deletions
@@ -2,6 +2,7 @@ package fi.lpam.gui.elementit;
import fi.lpam.Main;
import javafx.geometry.Insets;
import javafx.scene.control.Tab;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
@@ -10,25 +11,44 @@ import javafx.scene.text.FontWeight;
import java.util.Properties;
/**
* Käyttöliittymän pohja
* Käyttöliittymän välilehden pohja
*/
public class TabPohja extends StackPane {
public static Insets oletusInsets;
public static Border oletusBorder = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
public static String oletusStyle;
public static Font buttonFont;
public static Font tekstiFont;
public static double spacing;
public class TabPohja extends Tab {
public static Insets INSETS;
public static Border BORDER = new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), BorderWidths.DEFAULT));
public static String STYLE;
public static Font BUTTON_FONT;
public static Font TEKSTI_FONT;
public static double SPACING;
public TabPohja() {
protected BorderPane root = new BorderPane();
public TabPohja(String title) {
super(title);
Properties prop = Main.properties;
oletusInsets = new Insets(Double.parseDouble(prop.getProperty("insets")));
spacing = Double.parseDouble(prop.getProperty("insets"));
oletusStyle = "-fx-background-color: " + prop.getProperty("taustaVari") + ";";
buttonFont = Font.font(prop.getProperty("buttonFontti"), FontWeight.BOLD, Double.parseDouble(prop.getProperty("buttonFonttiKoko")));
tekstiFont = Font.font(prop.getProperty("tekstiFontti"), FontWeight.NORMAL, Double.parseDouble(prop.getProperty("tekstiFonttiKoko")));
this.setStyle(oletusStyle);
this.setPadding(oletusInsets);
this.setBorder(oletusBorder);
INSETS = new Insets(Double.parseDouble(prop.getProperty("insets")));
SPACING = Double.parseDouble(prop.getProperty("insets"));
STYLE = "-fx-background-color: " + prop.getProperty("taustaVari");
BUTTON_FONT = Font.font(prop.getProperty("buttonFontti"), FontWeight.BOLD, Double.parseDouble(prop.getProperty("buttonFonttiKoko")));
TEKSTI_FONT = Font.font(prop.getProperty("tekstiFontti"), FontWeight.NORMAL, Double.parseDouble(prop.getProperty("tekstiFonttiKoko")));
this.setStyle(
"-fx-font-size: " + Main.properties.getProperty("buttonFonttiKoko") + "px;" +
"-fx-font-weight: bold;" +
"-fx-font-family: " + Main.properties.getProperty("buttonFontti") + ";"
);
this.setClosable(false);
this.setOnSelectionChanged(e -> {if (e.getTarget() == this) päivitä();});
root.setStyle(STYLE);
root.setPadding(INSETS);
root.setBorder(BORDER);
this.setContent(root);
}
/**
* Metodi, jota kutsutaan kun tähän välilehteen palataan
* Luokan toteuttaja määrittää, mitä tarvitsee päivittää välilehteen palattaessa
*/
public void päivitä() {}
}