-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from yermak/development
Tip of the day
- Loading branch information
Showing
4 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/main/java/uk/yermak/audiobookconverter/fx/WizardDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package uk.yermak.audiobookconverter.fx; | ||
|
||
import javafx.scene.control.*; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.stage.Modality; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class WizardDialog extends Dialog<Void> { | ||
|
||
private final TextArea hintsArea = new TextArea(); | ||
private int currentIndex = 0; | ||
private List<String> hints; | ||
|
||
public WizardDialog(List<String> hints) { | ||
this.hints = hints; | ||
setTitle("Tip of the day..."); | ||
initModality(Modality.APPLICATION_MODAL); | ||
hintsArea.setMinHeight(200); | ||
hintsArea.setMinWidth(500); | ||
hintsArea.setEditable(false); | ||
hintsArea.setFocusTraversable(false); | ||
hintsArea.setWrapText(true); | ||
hintsArea.setFont(javafx.scene.text.Font.font("monospaced", 15)); | ||
|
||
DialogPane dialogPane = getDialogPane(); | ||
dialogPane.setContent(createWizardPane()); | ||
|
||
getDialogPane().getButtonTypes().addAll(ButtonType.PREVIOUS, ButtonType.NEXT, ButtonType.CLOSE); | ||
|
||
Button prevButton = (Button) getDialogPane().lookupButton(ButtonType.PREVIOUS); | ||
prevButton.setFocusTraversable(false); | ||
prevButton.addEventFilter(javafx.scene.input.MouseEvent.MOUSE_PRESSED, event -> { | ||
event.consume(); | ||
prev(); | ||
|
||
}); | ||
Button nextButton = (Button) getDialogPane().lookupButton(ButtonType.NEXT); | ||
nextButton.setFocusTraversable(false); | ||
nextButton.addEventFilter(javafx.scene.input.MouseEvent.MOUSE_PRESSED, event -> { | ||
event.consume(); | ||
next(); | ||
}); | ||
} | ||
|
||
private BorderPane createWizardPane() { | ||
BorderPane wizardPane = new BorderPane(); | ||
wizardPane.setPadding(new javafx.geometry.Insets(20)); | ||
|
||
hintsArea.setText(hints.get(currentIndex)); | ||
|
||
wizardPane.setCenter(hintsArea); | ||
|
||
return wizardPane; | ||
} | ||
|
||
private void next() { | ||
if (currentIndex < hints.size() - 1) { | ||
currentIndex++; | ||
} else { | ||
currentIndex = 0; | ||
} | ||
hintsArea.setText(hints.get(currentIndex)); | ||
} | ||
|
||
private void prev() { | ||
if (currentIndex > 0) { | ||
currentIndex--; | ||
} else { | ||
currentIndex = hints.size() - 1; | ||
} | ||
hintsArea.setText(hints.get(currentIndex)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters