本文整理汇总了Java中javafx.scene.control.Hyperlink.setOnAction方法的典型用法代码示例。如果您正苦于以下问题:Java Hyperlink.setOnAction方法的具体用法?Java Hyperlink.setOnAction怎么用?Java Hyperlink.setOnAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Hyperlink
的用法示例。
在下文中一共展示了Hyperlink.setOnAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHyperlink
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public static Hyperlink createHyperlink(final String string)
{
Hyperlink hyperlink = new Hyperlink(string);
hyperlink.setPadding(new Insets(0, 0, 0, 1));
hyperlink.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent event)
{
try
{
DesktopHelper.browse(string);
}
catch (Throwable e)
{
e.printStackTrace();
}
}
});
return hyperlink;
}
示例2: buildBugReportLink
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
private Hyperlink buildBugReportLink(Exception exception) {
Hyperlink link = new Hyperlink(BUG_REPORT_LINK);
String body;
try {
Throwable cause = exception.getCause();
// XXX: Can we include whole stack trace? URL length limitations? Privacy issues?
body = URLEncoder.encode(String.format("*Message:* `%s`\n*Cause:* `%s`", exception.getMessage(),
cause == null ? "(null)" : cause.getClass().getCanonicalName()), "UTF-8");
} catch (UnsupportedEncodingException e) {
System.err.println("Failed to build body argument for bug reporting URL");
e.printStackTrace();
body = "";
}
String args = "?body=" + body;
link.setOnAction(event -> directoryOpener.accept(BUG_REPORT_LINK + args));
return link;
}
示例3: showOpenFileButton
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
private void showOpenFileButton() {
Hyperlink link = new Hyperlink(Util.text("create-file-open"));
TextFlow flow = new TextFlow(new WikiLabel("create-file-success"), link);
flow.setTextAlignment(TextAlignment.CENTER);
addElement(flow);
link.setOnAction(ev -> {
try {
Desktop.getDesktop().open(Session.FILE);
} catch (IOException ex) {
LOGGER.log(Level.WARNING,
"Cannot open file: {0}",
new String[]{ex.getLocalizedMessage()}
);
}
});
nextButton.linkTo("StartPane", stage, true).setText(Util.text("create-file-back-to-start"));
nextButton.setVisible(true);
}
示例4: addLanguage
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
private void addLanguage(@NotNull Language language) {
if (containsLanguage(language)) {
return;
}
Hyperlink hyperlinkLanguage = new Hyperlink(language.getName());
links.add(hyperlinkLanguage);
links.sort(hyperlinkComparator);
hyperlinkLanguage.setUserData(language);
hyperlinkLanguage.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
hyperlinkLanguage.setVisited(false);
chosenLanguageObserver.updateValue(language);
}
});
getChildren().clear();
getChildren().addAll(links);
}
示例5: ItemDialog
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public ItemDialog(ExileToolsHit item) {
super(AlertType.INFORMATION);
setTitle(item.getInfo().getFullName());
setHeaderText("");
String json = new GsonBuilder().setPrettyPrinting().create()
.toJson(item.getHitJsonObject());
TextArea textArea = new TextArea(json);
textArea.setEditable(true);
textArea.setWrapText(false);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMinWidth(650);
textArea.setMinHeight(550);
String shopUrl = "https://www.pathofexile.com/forum/view-thread/" + item.getShop().getThreadid();
Hyperlink shopLink = new Hyperlink(shopUrl);
shopLink.setOnAction(e -> openLink(shopUrl));
getDialogPane().setContent(new VBox(textArea, shopLink));
initModality(Modality.NONE);
}
示例6: StartUpView
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public StartUpView( HostServices hostServices,
Stage stage,
Consumer<File> openFile ) {
VBox box = new AboutLogFXView( hostServices ).createNode();
String metaKey = FxUtils.isMac() ? "⌘" : "Ctrl+";
Hyperlink link = new Hyperlink( String.format( "Open file (%sO)", metaKey ) );
link.getStyleClass().add( "large-background-text" );
link.setOnAction( ( event ) -> new FileOpener( stage, openFile ) );
Text dropText = new Text( "Or drop files here" );
dropText.getStyleClass().add( "large-background-text" );
StackPane fileDropPane = new StackPane( dropText );
fileDropPane.getStyleClass().add("drop-file-pane");
FileDragAndDrop.install( fileDropPane, openFile );
box.getChildren().addAll( link, fileDropPane );
getChildren().addAll( box );
}
示例7: BottomPane
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public BottomPane() {
Hyperlink bottomLabel = new Hyperlink("http://bluemarlinexile.github.io/");
bottomLabel.setOnAction(e -> {
try {
SwingUtil.openUrlViaBrowser(bottomLabel.getText());
} catch (Exception e1) {
e1.printStackTrace();
}
});
Label indexerLastUpdateText = new Label("Indexer Last Update: ");
Label indexerLastUpdateValueText = new Label();
indexerLastUpdateValueText.textProperty().bind(lastIndexUpdateService.messageProperty());
indexerLastUpdateText.textProperty().bind(lastIndexUpdateService.countdownProperty());
getChildren().addAll(bottomLabel, new HBoxSpacer(), indexerLastUpdateText, indexerLastUpdateValueText);
lastIndexUpdateService.setOnSucceeded(e -> lastIndexUpdateService.restart());
lastIndexUpdateService.setOnFailed (e -> lastIndexUpdateService.restart());
lastIndexUpdateService.restart();
}
示例8: addBrowser
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
/**
*
*
* @param fileEntry
* @param contentSearch
* @param nodesToAdd
* @param idToShow
*
* @throws Exception
*/
private void addBrowser(final FileEntry fileEntry, final List<Node> nodesToAdd) throws Exception {
// TODO: text
final Hyperlink fulltextButton = new Hyperlink(g.getText("SEARCH_RESULT.SHOW_FULLTEXT"));
fulltextButton.setStyle("-fx-font-size:15px");
Platform.runLater(new Runnable() {
@Override
public void run() {
addTooltip(fulltextButton, g.getText("SEARCH_RESULT.SHOW_FULLTEXT_TOOLTIP"), -50, 35);
}
});
// ------------------------------------------------ //
fulltextButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
outTransition();
executeWorker(saveToXhtmlWorker(fileEntry));
}
});
// ------------------------------------------------ //
nodesToAdd.add(fulltextButton);
nodesToAdd.add(new Text(" "));
}
示例9: addDirectoryButton
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
/**
*
*
* @param fileEntry
* @param nodesToAdd
*
* @throws Exception
*/
private void addDirectoryButton(final FileEntry fileEntry, final List<Node> nodesToAdd)
throws Exception {
Hyperlink openDirButton = new Hyperlink(g.getText("SEARCH_RESULT.SHOW_FILE"));
openDirButton.setStyle("-fx-font-size:15px");
// addImageIcon(openDirButton, Icon.FOLDER_OPEN, 0);
openDirButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
outTransition();
inTransitionAsWorker(1000);
executeWorker(openFileWorker(fileEntry.getPath(), true, 1));
}
});
nodesToAdd.add(openDirButton);
nodesToAdd.add(new Text(" "));
Platform.runLater(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName(Config.APP_NAME + "JavaFX: Open dir tooltip");
addTooltip(openDirButton, g.getText("SEARCH_RESULT.OPEN_DIR_TOOLTIP"), -50, 35);
}
});
}
示例10: StartSplashStage
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public StartSplashStage(Window owner) {
initModality(Modality.WINDOW_MODAL);
initOwner(owner);
initStyle(StageStyle.UTILITY);
Text windowTitle = new Text("LPDS Parking");
Hyperlink openLink = new Hyperlink("Open scenario");
Hyperlink newLink = new Hyperlink("New scenario");
Hyperlink exitLink = new Hyperlink("Exit");
windowTitle.setFont(Font.font("Arial", FontWeight.BOLD, 14));
exitLink.setOnAction(event -> setResult(0));
openLink.setOnAction(event -> setResult(1));
newLink.setOnAction(event -> setResult(2));
VBox vbox = new VBox(windowTitle, newLink, openLink, exitLink);
vbox.setPadding(new Insets(10));
vbox.setSpacing(8);
for (Node node : vbox.getChildren())
VBox.setMargin(node, new Insets(0, 0, 0, 8));
setScene(new Scene(vbox));
sizeToScene();
}
示例11: populate
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public void populate(Script script) {
this.flow = new TextFlow();
Text name = new Text(script.getName());
name.getStyleClass().add("subtitle");
this.getChildren().add(name);
RootNode node = mdProcessor.parseMarkdown(script.getDescription().toCharArray());
//Text desc = new Text(script.getDescription());
//this.getChildren().add(desc);
node.accept(this.mdToFx);
//add description flow
this.getChildren().add(flow);
final String documentationPage = script.getXProcScript().getHomepage();
if (documentationPage != null && documentationPage.isEmpty() == false) {
Hyperlink link = new Hyperlink();
link.setText("Read online documentation");
link.setOnAction(Links.getEventHander(main.getHostServices(),documentationPage));
this.getChildren().add(link);
}
}
示例12: addFinderLinkRow
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public void addFinderLinkRow(String label, final String path) {
Hyperlink link = new Hyperlink();
link.setText(label);
link.setTooltip(new Tooltip(path));
link.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
try {
String cmd = PlatformUtils.getFileBrowserCommand() + " " + path;
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
addRow(link);
}
示例13: checkForUpdateOnStartupCheckbox
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
private Node checkForUpdateOnStartupCheckbox() {
HBox result = new HBox(15);
result.paddingProperty().setValue(new Insets(10, 0, 0, 0));
CheckBox checkBox = new CheckBox();
checkBox.selectedProperty().bindBidirectional(userPreferences.searchUpdateAtStartupProperty());
result.getChildren().add(checkBox);
Label label = new Label(bundle.getString("ui.about.update.message.checkOnStartup"));
label.getStyleClass().add("legend");
result.getChildren().add(label);
Hyperlink preferencesLink = new Hyperlink(bundle.getString("ui.menu.file.preferences"));
preferencesLink.setOnAction((actionEvent) -> new PreferencesWindow(bundle, userPreferences, applicationData).show());
preferencesLink.getStyleClass().add("legend");
result.getChildren().add(preferencesLink);
return result;
}
示例14: onStart
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
@Override
public void onStart() {
stuffBox.prefWidthProperty().bind(Main.mainController.contentBox.widthProperty());
stuffBox.prefHeightProperty().bind(Main.mainController.contentBox.heightProperty());
if (credits.getChildren().isEmpty()) {
String yearString = "2017";
int year = Calendar.getInstance().get(Calendar.YEAR);
if (year > 2017) {
yearString += "-" + year;
}
Text text = new Text("©" + yearString + " - HEARTH PROJECT");
text.setStyle("-fx-fill: #FFFFFF; -fx-font-family: 'Lato', sans-serif; -fx-font-size: 12;");
Hyperlink hyperlink = new Hyperlink("http://hearthproject.uk/");
hyperlink.setStyle("-fx-text-fill: #FFFFFF; -fx-font-family: 'Lato', sans-serif; -fx-font-size: 12;");
hyperlink.setOnAction(e -> openHearthSite());
hyperlink.focusTraversableProperty().setValue(false);
Text creditsText = new Text("\nCredits:");
creditsText.setStyle("-fx-fill: #FFFFFF; -fx-font-family: 'Lato', sans-serif; -fx-font-size: 14; -fx-font-weight: bold");
credits.getChildren().addAll(text, hyperlink, creditsText);
addCredit("modmuss50 - Lead Developer", "https://twitter.com/modmuss50");
addCredit("Prospector - UX Manager", "https://twitter.com/ProfProspector");
addCredit("primetoxinz - Various Contributions", "https://github.com/primetoxinz");
addCredit("loading.io - Splash Loading .gif", "https://loading.io/");
addCredit("Yannick - Home, About, Download, Instances, and Update icons", "https://www.flaticon.com/authors/yannick");
addCredit("Gregor Cresnar - Package icon", "https://www.flaticon.com/authors/gregor-cresnar");
addCredit("Egor Rumyantsev - Settings icon", "https://www.flaticon.com/authors/egor-rumyantsev");
addCredit("Icomoon - Log Out icon", "https://www.flaticon.com/authors/icomoon");
}
}
示例15: addCredit
import javafx.scene.control.Hyperlink; //导入方法依赖的package包/类
public void addCredit(String credit, String url) {
Hyperlink hyperlink = new Hyperlink(credit);
hyperlink.setStyle("-fx-text-fill: #FFFFFF; -fx-font-family: 'Lato', sans-serif; -fx-font-size: 12;");
hyperlink.setOnAction((actionEvent) -> OperatingSystem.browseURI(url));
hyperlink.focusTraversableProperty().setValue(false);
credits.getChildren().add(hyperlink);
}