util
Clone or download
Modified Files
/*
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
Originally Written by : Debayan Sutradhar (rnayabed)
Originally Written by : Debayan Sutradhar (rnayabed)
*/
*/
package com.stream_pi.util.uihelper;
package com.stream_pi.util.uihelper;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.CheckBox;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
public class HBoxInputBox extends HBox {
public class HBoxInputBox extends HBox {
private TextField textField;
private TextField textField;
public HBoxInputBox(String labelText, TextField textField, int prefWidth, CheckBox enablerCheckBox)
public HBoxInputBox(String labelText, TextField textField, int prefWidth, CheckBox enablerCheckBox)
{
{
textField.setPrefWidth(prefWidth);
textField.setPrefWidth(prefWidth);
Label label = new Label(labelText);
Label label = new Label(labelText);
label.setWrapText(true);
label.setAlignment(Pos.CENTER_LEFT);
label.prefHeightProperty().bind(heightProperty());
getChildren().addAll(label, SpaceFiller.horizontal(), textField);
getChildren().addAll(label, SpaceFiller.horizontal(), textField);
if(enablerCheckBox != null)
if(enablerCheckBox != null)
{
{
textField.disableProperty().bind(enablerCheckBox.selectedProperty());
textField.disableProperty().bind(enablerCheckBox.selectedProperty());
HBox.setMargin(enablerCheckBox, new Insets(0, 0, 0, 45));
HBox.setMargin(enablerCheckBox, new Insets(0, 0, 0, 45));
getChildren().add(enablerCheckBox);
getChildren().add(enablerCheckBox);
}
}
this.textField = textField;
this.textField = textField;
}
}
public HBoxInputBox(String labelText, TextField textField, CheckBox enablerCheckBox)
public HBoxInputBox(String labelText, TextField textField, CheckBox enablerCheckBox)
{
{
this(labelText, textField, 100, enablerCheckBox);
this(labelText, textField, 100, enablerCheckBox);
}
}
public HBoxInputBox(String labelText, TextField textField)
public HBoxInputBox(String labelText, TextField textField)
{
{
this(labelText, textField, 100, null);
this(labelText, textField, 100, null);
}
}
public HBoxInputBox(String labelText, TextField textField, int prefWidth)
public HBoxInputBox(String labelText, TextField textField, int prefWidth)
{
{
this(labelText, textField, prefWidth, null);
this(labelText, textField, prefWidth, null);
}
}
public TextField getTextField()
public TextField getTextField()
{
{
return textField;
return textField;
}
}
}
}
package com.stream_pi.util.uihelper;
package com.stream_pi.util.uihelper;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
public class HBoxWithSpaceBetween extends HBox
public class HBoxWithSpaceBetween extends HBox
{
{
public HBoxWithSpaceBetween(Node node1, Node node2, double spacing)
public HBoxWithSpaceBetween(Node node1, Node node2, double spacing)
{
{
getChildren().addAll(
make(node1, node2, spacing);
node1,
SpaceFiller.horizontal(),
node2
);
setSpacing(spacing);
}
}
public HBoxWithSpaceBetween(Node node1, Node node2)
public HBoxWithSpaceBetween(Node node1, Node node2)
{
{
this(node1, node2, 5.0);
make(node1, node2, 5.0);
}
}
public HBoxWithSpaceBetween(String labelText, Node node2)
public HBoxWithSpaceBetween(String labelText, Node node2)
{
{
this(new Label(labelText), node2);
Label label = new Label(labelText);
label.setWrapText(true);
label.setAlignment(Pos.CENTER_LEFT);
label.prefHeightProperty().bind(heightProperty());
make(label, node2, 5.0);
}
public void make(Node node1, Node node2, double spacing)
{
getChildren().addAll(
node1,
SpaceFiller.horizontal(),
node2
);
setSpacing(spacing);
}
}
}
}