Skip to content

Commit

Permalink
More cleanup with statics and use of Color.web() to replace Color.rgb()
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole authored and DavidArthurCole committed Apr 19, 2022
1 parent 2c5872d commit 5749a6b
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/main/java/com/BHBMainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,23 +555,8 @@ private LimitedTextField makeCodeEnterField(Label codeColorLabel, int id){
colorCodeEnterField.focusedProperty().addListener(listener -> lastEnteredField = colorCodeEnterField);
colorCodeEnterField.setOnKeyPressed(e -> {if(ctrlZ.match(e)) undoChange();});
colorCodeEnterField.textProperty().addListener((observable, oldValue, newValue) -> {

if(isHexOk(newValue)){
codeColorLabel.setBackground(new Background(new BackgroundFill(Color.rgb(
Integer.parseInt(newValue.substring(0,2),16),
Integer.parseInt(newValue.substring(2,4),16),
Integer.parseInt(newValue.substring(4,6),16)), CornerRadii.EMPTY, Insets.EMPTY)));
}
else{
if(currentTheme.getValue().equals("DARK")) codeColorLabel.setBackground(new Background(new BackgroundFill(Color.rgb(92, 100, 108), CornerRadii.EMPTY, Insets.EMPTY)));
else{
codeColorLabel.setBackground(new Background(new BackgroundFill(Color.rgb(
Integer.parseInt("F2",16),
Integer.parseInt("F2",16),
Integer.parseInt("F2",16)), CornerRadii.EMPTY, Insets.EMPTY)));
}

}
if(isHexOk(newValue)) codeColorLabel.setBackground(new Background(new BackgroundFill(Color.web(newValue), CornerRadii.EMPTY, Insets.EMPTY)));
else codeColorLabel.setBackground(currentTheme.getValue().equals("DARK") ? DARK_BACKGROUND : DEF_BACKGROUND);
unlockFields();
updatePreviewBHB();
updateTextFieldFontSize(colorCodeEnterField);
Expand Down

0 comments on commit 5749a6b

Please sign in to comment.