Skip to content

Commit

Permalink
Updated CharityPageController
Browse files Browse the repository at this point in the history
Added method for opening browser and navigating to the url of the charity on IK.
  • Loading branch information
roaraf committed Apr 18, 2026
1 parent 57fdb66 commit 7ba0277
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.io.ByteArrayInputStream;
import java.util.Objects;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
Expand All @@ -25,6 +25,8 @@ public class CharityPageController {

@FXML private ImageView CharityLogo;

@FXML private Hyperlink CharityURL;

@FXML
public void initialize() {}

Expand Down Expand Up @@ -53,7 +55,8 @@ public void setCharity(Charity charity) {
this.CharityLogo.setImage(CharityLogoImage);
} else {
String placeholderImagePath =
Objects.requireNonNull(getClass().getResource("/images/leggTilBilde.jpg")).toExternalForm();
Objects.requireNonNull(getClass().getResource("/images/leggTilBilde.jpg"))
.toExternalForm();
Image placeholderImage = new Image(placeholderImagePath);
this.CharityLogo.setImage(placeholderImage);
}
Expand Down Expand Up @@ -91,4 +94,15 @@ public void handleSearch(ActionEvent event) {

LoaderScene.LoadScene("availableOrganization", event, null, query);
}

@FXML
public void handleHomepageClick(ActionEvent event) {
try {
String url = this.charity.getURL();
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
} catch (Exception e) {
System.out.println("Something went wrong when opening URL.");
e.printStackTrace();
}
}
}

0 comments on commit 7ba0277

Please sign in to comment.