add a close button

This commit is contained in:
Denis-Cosmin NUTIU 2024-04-07 17:50:25 +03:00
parent 525a25769b
commit 74d0bb5fe7
2 changed files with 19 additions and 1 deletions

View file

@ -1,15 +1,18 @@
package dev.nuculabs.imagetagger.ui.pages
import javafx.application.Platform
import javafx.fxml.FXML
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.scene.control.Button
import javafx.stage.Stage
import java.awt.Desktop
import java.net.URL
class AboutPage {
lateinit var closeButton: Button
@FXML
fun openBlog() {
@ -21,6 +24,15 @@ class AboutPage {
Desktop.getDesktop().browse(URL("https://github.com/dnutiu/ImageTagger").toURI());
}
@FXML
fun closePage() {
Platform.runLater {
// Get a reference to the stage
val stage = closeButton.scene.window as Stage
stage.hide()
}
}
companion object {
fun show() {
val fxmlLoader = FXMLLoader(AboutPage::class.java.getResource("about-page.fxml"))

View file

@ -42,6 +42,12 @@
<FontIcon iconLiteral="fab-github" iconSize="16"/>
</graphic>
</Hyperlink>
<HBox alignment="CENTER_RIGHT" prefWidth="Infinity">
<Button fx:id="closeButton" text="Close" onAction="#closePage">
<graphic>
<FontIcon iconLiteral="fas-window-close" iconSize="16"/>
</graphic>
</Button>
</HBox>
</VBox>
</AnchorPane>