本文整理汇总了Java中javafx.scene.control.Hyperlink类的典型用法代码示例。如果您正苦于以下问题:Java Hyperlink类的具体用法?Java Hyperlink怎么用?Java Hyperlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hyperlink类属于javafx.scene.control包,在下文中一共展示了Hyperlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: click
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
@Test public void click() {
Hyperlink button = (Hyperlink) getPrimaryStage().getScene().getRoot().lookup(".hyperlink");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(new Runnable() {
@Override public void run() {
RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
Point2D sceneXY = button.localToScene(new Point2D(3, 3));
PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
Point2D screenXY = button.localToScreen(new Point2D(3, 3));
MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
rfxButtonBase.mouseButton1Pressed(me);
}
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording select = recordings.get(0);
AssertJUnit.assertEquals("click", select.getCall());
AssertJUnit.assertEquals("", select.getParameters()[0]);
}
示例2: 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;
}
示例3: mergeFailed
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
private void mergeFailed(Exception exception) {
Platform.runLater(() -> {
Text text = new Text(
String.format("Merging failed.\nProblem: %s\nIf you think this is a bug, please report it here:",
exception.getMessage()));
text.setWrappingWidth(CONTENT_WIDTH);
text.setFill(Color.WHITE); // XXX: Ugly workaround because CSS doesn't work
Hyperlink link = buildBugReportLink(exception);
FlowPane content = new FlowPane(text, link);
ThemedAlert alert = new ThemedAlert(AlertType.ERROR);
alert.getDialogPane().setContent(content);
alert.showAndWait();
System.exit(1);
});
}
示例4: 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;
}
示例5: lvFindRsltOnMouseClick
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
/**
* 리스트뷰를 클릭했을때 이벤트
* @작성자 : KYJ
* @작성일 : 2017. 7. 25.
* @param e
*/
public void lvFindRsltOnMouseClick(MouseEvent e) {
FindModel selectedItem = lvFindRslt.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
this.pagination.setCurrentPageIndex(selectedItem.getPage());
List<Hyperlink> collect = IntStream.iterate(0, a -> a + 1).limit(selectedItem.getLines().size()).mapToObj(idx -> {
Line line = selectedItem.getLines().get(idx);
Hyperlink hyperlink = new Hyperlink(String.format("%d", line.getLine()));
hyperlink.setOnAction(ev -> {
CPagenationSkin skin = (CPagenationSkin) pagination.getSkin();
SimpleTextView view = (SimpleTextView) skin.getCurrentPage();
view.getHelper().moveToLine(line.getLine(), line.getStartCol() - 1, line.getEndCol() - 1);
});
return hyperlink;
}).collect(Collectors.toCollection(LinkedList::new));
this.fpLines.getChildren().setAll(collect);
}
}
示例6: 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);
}
示例7: setContent
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
private void setContent() {
addElement("check-intro", 40);
Session.FILES_TO_UPLOAD.stream().map(uploadElement -> {
String name = uploadElement.getData("name");
Hyperlink label = new Hyperlink(name);
label.setTooltip(new Tooltip(name));
label.setOnAction(event -> {
setDetails(uploadElement, label);
});
return label;
}).forEach(label -> {
fileListContainer.getChildren().add(label);
});
addElementRow(10,
new Node[]{new WikiScrollPane(fileListContainer).setWidth(250), new WikiScrollPane(detailsContainer)},
new Priority[]{Priority.SOMETIMES, Priority.SOMETIMES}
);
setDetails(Session.FILES_TO_UPLOAD.get(0), (Hyperlink) fileListContainer.getChildren().get(0));
prevButton.linkTo("LoadPane", stage);
nextButton.linkTo("LoginPane", stage);
}
示例8: LanguageSelectionPane
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
public LanguageSelectionPane(@Nullable Language defaultPreviewLanguage) {
super(10, 10);
this.defaultLanguage = defaultPreviewLanguage;
setToKey(null);
chosenLanguageObserver.addListener(new ValueListener<Language>() {
@Override
public void valueUpdated(@NotNull ValueObserver<Language> observer, @Nullable Language oldValue, @Nullable Language newValue) {
for (Hyperlink hyperlink : links) {
if (hyperlink.getUserData().equals(newValue)) {
hyperlink.setStyle(LanguageSelectionPane.SELECTED_LINK_STYLE);
} else {
hyperlink.setStyle("");
}
}
}
});
}
示例9: 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);
}
示例10: alertWithExpandableContentTest
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
@Test(timeout = 300000)
public void alertWithExpandableContentTest() throws Throwable {
Wrap<? extends Node> button = parent.lookup(Button.class, new ByText<Button>(BUTTON_SHOW_EXP_TEXT)).wrap();
for (StageStyle s : StageStyle.values()) {
Wrap<? extends Node> styleToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(s.toString())).wrap();
click(styleToggleButton, InputType.MOUSE);
for (String c : content) {
Wrap<? extends Node> contentToggleButton = parent.lookup(ToggleButton.class, new ByText<ToggleButton>(c)).wrap();
click(contentToggleButton, InputType.MOUSE);
click(button, InputType.MOUSE);
Thread.sleep(DEFAULT_DELAY);
SceneDock sd = new SceneDock();
click(sd.asParent().lookup(Hyperlink.class, new ByText<Hyperlink>("Show Details")).wrap(), InputType.MOUSE);
// checkScreenshot("alertWithExpandableContentTest" + s + "_" + c + "Test", scene);
Thread.sleep(DEFAULT_DELAY);
closeDialogWindowByClickingButton("OK");
throwScreenshotError();
}
}
}
示例11: hyperlinkActionTest
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
/**
* Test of user input processing
*/
@ScreenshotCheck
@Test(timeout = 300000)
public void hyperlinkActionTest() throws InterruptedException {
openPage(Pages.Action.name());
try {
Thread.sleep(1000); // ugly workaround to be removed ASAP
} catch (InterruptedException ex) {
}
Parent<Node> parent = getScene().as(Parent.class, Node.class);
Wrap<? extends Hyperlink> label = parent.lookup(Hyperlink.class, new ByID<Hyperlink>(IDs.Target.name())).wrap();
final Wrap<? extends Hyperlink> hyperlink = parent.lookup(Hyperlink.class, new ByID<Hyperlink>(IDs.Hyperlink.name())).wrap();
hyperlink.mouse().click();
label.waitProperty(Wrap.TEXT_PROP_NAME, HyperlinkApp.HYPER_LINK_IS_FIRED);
assertTrue(new GetAction<Boolean>() {
@Override
public void run(Object... os) throws Exception {
setResult(hyperlink.getControl().isVisited());
}
}.dispatch(Root.ROOT.getEnvironment()));
}
示例12: generateHyperlink
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
Hyperlink generateHyperlink(String text, String url, String imagePath) {
Hyperlink link = new Hyperlink(text);
InputStream imageStream = Undertailor.class.getResourceAsStream("/assets/" + imagePath);
if (imageStream != null) {
ImageView img = new ImageView(new Image(imageStream));
img.setFitHeight(24);
img.setFitWidth(24);
link.setGraphic(img);
link.setGraphicTextGap(8D);
}
link.setOnMouseReleased(event -> {
DesktopLauncher.instance.getHostServices().showDocument(url);
});
return link;
}
示例13: initControls
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
@Override
public void initControls()
{
this.projectRepoLabel = new Label("Project Repository");
this.projectRepoValue = new Hyperlink("https://github.com/AstromechZA/bunkr");
this.versionLabel = new Label("Version");
this.versionValue = new Label(Version.versionString);
this.compatVersionLabel = new Label("Compatible Version");
this.compatVersionValue = new Label(Version.compatibleVersionString);
this.gitCommitDateLabel = new Label("Git Commit Date");
this.gitCommitDateValue = new Label(Version.gitDate);
this.gitCommitHashLabel = new Label("Git Commit Hash");
this.gitCommitHashValue = new Label(Version.gitHash);
this.buildDateLabel = new Label("Build Date");
this.buildDateValue = new Label(Version.builtDate);
}
示例14: 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);
}
示例15: buildFrom
import javafx.scene.control.Hyperlink; //导入依赖的package包/类
/**
* @param title
* @param url
* @return
* @since 2.10.0
*/
public static Hyperlink buildFrom(final String title, final String url) {
final Hyperlink ret = new Hyperlink(title);
ret.setOnMouseClicked(mouseEvent -> {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
try {
final Desktop desktop = getDesktop();
desktop.browse(new URI(url));
} catch (final Exception e) {
log.error("An error occurred trying to open the infolink in the default browser: ", e);
showExceptionDialog(e);
}
}
});
return ret;
}