use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.
the class MakeATransactionController method exCreateSectorBtn.
// function for creating a sector
@FXML
private void exCreateSectorBtn(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Create Sector");
dialog.setHeaderText("Create your expenditure sector, where you expense Tk.");
dialog.setContentText("Please Type a Name :");
Stage MakeATransactionStage = (Stage) exbtnCreateSector.getScene().getWindow();
dialog.setX(MakeATransactionStage.getX() + 150);
dialog.setY(MakeATransactionStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String typedName = result.get();
if (typedName.length() == 0) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Operation Failed");
alert.setHeaderText(null);
alert.setContentText("Write a Sector Name Please");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else if (countWords(typedName) == 0) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Operation Failed");
alert.setHeaderText(null);
alert.setContentText("Write a Sector Name Please");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else if (new Sector().createSector(typedName)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Operation Failed");
alert.setHeaderText(null);
alert.setContentText("Sector Name Already Exist");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
new Sector().createSector(typedName);
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Sector " + typedName + " created successfully");
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
exLoadSector();
excmboSector.getSelectionModel().selectLast();
}
}
}
use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.
the class MakeATransactionController method bnkAdjustBalAction.
@FXML
private void bnkAdjustBalAction(ActionEvent event) {
if (bnkSelectedTabName.equals("bKash")) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Adjust bKash Balance");
dialog.setHeaderText("Provide Balance Status at Your bKash Account.");
dialog.setContentText("Please enter the amount:");
Stage MakeATransactionStage = (Stage) bkbtnAdjustBalance.getScene().getWindow();
dialog.setX(MakeATransactionStage.getX() + 200);
dialog.setY(MakeATransactionStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String typedAmount = result.get();
if (!validAmount(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText(InvalidInput);
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else if (amountIsZero(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero is not approved.");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
bnkAdjustBtnPressed = true;
long dbbKashBalance = currentbKashBalance();
long typedBalance = stringToLong(typedAmount);
bnkAdjustBalAfter = typedAmount;
if (dbbKashBalance < typedBalance) {
bnkAdjustAmount = "added " + longToString(typedBalance - dbbKashBalance) + " to Account";
} else if (dbbKashBalance > typedBalance) {
bnkAdjustAmount = UnitConverter.longToString((dbbKashBalance - typedBalance));
} else {
bnkAdjustAmount = "0.00";
}
bnkSaveFunction();
}
}
} else if (bnkSelectedTabName.equals("Rocket")) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Adjust Rocket Balance");
dialog.setHeaderText("Provide Balance Status at Your Rocket Account.");
dialog.setContentText("Please enter the amount:");
Stage MakeATransactionStage = (Stage) rocbtnAdjustBalance.getScene().getWindow();
dialog.setX(MakeATransactionStage.getX() + 200);
dialog.setY(MakeATransactionStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String typedAmount = result.get();
if (!validAmount(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText(InvalidInput);
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else if (amountIsZero(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero is not approved.");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
bnkAdjustBtnPressed = true;
long dbrocketBalance = currentRocketBalance();
long typedBalance = stringToLong(typedAmount);
bnkAdjustBalAfter = typedAmount;
if (dbrocketBalance < typedBalance) {
bnkAdjustAmount = "added " + longToString(typedBalance - dbrocketBalance) + " to Account";
} else if (dbrocketBalance > typedBalance) {
bnkAdjustAmount = UnitConverter.longToString((dbrocketBalance - typedBalance));
} else {
bnkAdjustAmount = "0.00";
}
bnkSaveFunction();
}
}
}
bnkAdjustBtnPressed = false;
}
use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.
the class MakeATransactionController method exAdjustBalance.
// this function will let user to adjust their balance
@FXML
private void exAdjustBalance(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Adjust Wallet Balance");
dialog.setHeaderText("Provide Balance Status at Your Hand Now.");
dialog.setContentText("Please enter the amount:");
Stage MakeATransactionStage = (Stage) exbtnAdjustBalance.getScene().getWindow();
dialog.setX(MakeATransactionStage.getX() + 200);
dialog.setY(MakeATransactionStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String typedAmount = result.get();
if (!validAmount(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText(InvalidInput);
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else if (amountIsZero(typedAmount)) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero is not approved.");
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
adjustBtnPressed = true;
long dbWalletBalance = currentWalletBalance();
long typedBalance = stringToLong(typedAmount);
exAdjustBalAfter = typedAmount;
if (dbWalletBalance < typedBalance) {
exAdjustAmount = "added " + longToString(typedBalance - dbWalletBalance) + " to Wallet";
} else if (dbWalletBalance > typedBalance) {
exAdjustAmount = exWalletBalanceAfter(typedAmount);
} else {
exAdjustAmount = "0.0";
}
exSaveFunction();
}
}
adjustBtnPressed = false;
}
use of javafx.scene.control.TextInputDialog in project Money-Manager by krHasan.
the class SettingsController method changePassword.
@FXML
private void changePassword(ActionEvent event) {
try {
if (!passwordChangeClicked) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Password Change");
dialog.setHeaderText("Enter password for authentication");
dialog.setContentText("Your Password :");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
dialog.setX(SettingsStage.getX() + 200);
dialog.setY(SettingsStage.getY() + 170);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
if (getPassword().equals(result.get())) {
systemtxtPassword.setDisable(false);
systemtxtPassword.clear();
systemlblRePassword.setVisible(true);
systemtxtRePassword.setVisible(true);
systembtnChangePassword.setText("Save Password");
passwordChangeClicked = true;
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Message");
alert.setHeaderText(null);
alert.setContentText("Wrong Password");
alert.setX(SettingsStage.getX() + 200);
alert.setY(SettingsStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
} else {
if (!systemtxtPassword.getText().equals(systemtxtRePassword.getText())) {
systemlblWarningMsg.setText("Password didn't match");
} else {
setPassword(systemtxtPassword.getText());
passwordChangeClicked = false;
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Information updated successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
tabSystemInitialize();
}
}
} catch (Exception e) {
}
}
use of javafx.scene.control.TextInputDialog in project blue by kunstmusik.
the class PresetPane method addPreset.
/**
* @param currentPresetGroup
*/
private void addPreset(PresetGroup currentPresetGroup) {
TextInputDialog dlg = new TextInputDialog();
dlg.setTitle("Enter Preset Name");
dlg.setHeaderText("Enter Preset Name");
dlg.setGraphic(null);
BlueFX.style(dlg.getDialogPane());
Optional<String> str = dlg.showAndWait();
if (!str.isPresent() || str.get().length() == 0) {
return;
}
Preset preset = Preset.createPreset(bsbInterface);
preset.setPresetName(str.get());
currentPresetGroup.getPresets().add(preset);
Collections.sort(currentPresetGroup.getPresets());
getPresetGroup().setCurrentPresetUniqueId(preset.getUniqueId());
getPresetGroup().setCurrentPresetModified(false);
updatePresetMenu();
updateCurrentPresetUI();
}
Aggregations