Quicklaunch/QuickLaunch/src/mod_quicklaunch/ShortcutEntryPane.java
2019-04-14 12:18:58 +02:00

88 lines
2.1 KiB
Java

package mod_quicklaunch;
import javafx.geometry.Pos;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
public class ShortcutEntryPane extends Pane{
private CheckBox checkBox;
private TextField shortcutField;
private TextField pathField;
public ShortcutEntryPane(Shortcut cut,int layoutY) {
this.setPrefWidth(600);
this.setPrefHeight(35);
this.setLayoutX(0);
this.setLayoutY(layoutY);
checkBox = new CheckBox();
checkBox.setLayoutX(8);
checkBox.setLayoutY(8);
checkBox.setPrefWidth(18);
checkBox.setPrefHeight(18);
checkBox.setVisible(false);
shortcutField = new TextField();
shortcutField.setText(cut.getShortcut());
shortcutField.setPrefWidth(92);
shortcutField.setPrefHeight(27);
shortcutField.setLayoutX(8);
shortcutField.setLayoutY(4);
shortcutField.setAlignment(Pos.CENTER);
shortcutField.setEditable(false);
shortcutField.setStyle("-fx-text-fill: gray");
pathField = new TextField();
pathField.setText(cut.getPath());
pathField.setPrefWidth(497);
pathField.setPrefHeight(27);
pathField.setLayoutX(100);
pathField.setLayoutY(4);
pathField.setEditable(false);
pathField.setStyle("-fx-text-fill: gray");
this.getChildren().add(checkBox);
this.getChildren().add(shortcutField);
this.getChildren().add(pathField);
}
public String getShortcut() {
return shortcutField.getText();
}
public String getPath() {
return pathField.getText();
}
public boolean isChecked() {
return checkBox.isSelected();
}
public void setEditable(boolean value) {
shortcutField.setEditable(value);
pathField.setEditable(value);
if(value) {
shortcutField.setStyle("-fx-text-fill: black");
pathField.setStyle("-fx-text-fill: black");
checkBox.setVisible(true);
shortcutField.setPrefWidth(70);
shortcutField.setLayoutX(30);
}
else {
shortcutField.setStyle("-fx-text-fill: gray");
pathField.setStyle("-fx-text-fill: gray");
checkBox.setVisible(false);
shortcutField.setPrefWidth(92);
shortcutField.setLayoutX(8);
}
}
public void focus() {
shortcutField.requestFocus();
}
}