Created
August 29, 2013 23:41
-
-
Save skrb/6384723 to your computer and use it in GitHub Desktop.
Hyperlink Demo
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
import javafx.application.Application; | |
import javafx.event.ActionEvent; | |
import javafx.event.EventHandler; | |
import javafx.geometry.Pos; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Hyperlink; | |
import javafx.scene.control.Label; | |
import javafx.scene.layout.BorderPane; | |
import javafx.scene.layout.FlowPane; | |
import javafx.scene.web.WebEngine; | |
import javafx.scene.web.WebView; | |
import javafx.stage.Stage; | |
public class Test extends Application { | |
@Override | |
public void start(Stage stage) { | |
BorderPane root = new BorderPane(); | |
WebView view = new WebView(); | |
root.setCenter(view); | |
final WebEngine engine = view.getEngine(); | |
FlowPane flow = new FlowPane(); | |
flow.setAlignment(Pos.CENTER); | |
root.setTop(flow); | |
Label label1 = new Label("This is link to"); | |
Hyperlink link = new Hyperlink("http://google.co.jp/"); | |
Label label2 = new Label(" Please click the LINK."); | |
flow.getChildren().addAll(label1, link, label2); | |
link.setOnAction(new EventHandler<ActionEvent>() { | |
@Override | |
public void handle(ActionEvent event) { | |
engine.load("http://google.co.jp/"); | |
} | |
}); | |
Scene scene = new Scene(root, 600, 800); | |
stage.setScene(scene); | |
stage.show(); | |
} | |
public static void main(String... args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment