javafx

JavaFx 8: open a link in a browser without reference to Application

喜欢而已 提交于 2019-12-30 03:07:23
问题 Have got a Hyperlink. When clicked I want a link to be opened in an external browser. The usual method cited on the web seems to be: final Hyperlink hyperlink = new Hyperlink("http://www.google.com"); hyperlink.setOnAction(t -> { application.getHostServices().showDocument(hyperlink.getText()); }); However I don't have a reference to Application . The link is opened from Dialog, which is opened from a Controller, which is opened via an fxml file, so getting a reference to the Application

Javafx combobox styling

烈酒焚心 提交于 2019-12-30 01:24:07
问题 I need a combobox in javaFX whose popup behavior can be controlled, like upon clicking the combobox, instead of default behavior where it shows a drop down, i want the drop down to be shown above the combobox (insetad of display below the combobox) . Is it possible ? Can we do this with css ? Thanks for any help. 回答1: I hope this will work for you. Make some changes according your need .combo-box .list-cell { -fx-background: white; -fx-background-color: transparent; -fx-text-fill: -fx-text

JavaFX 2 vs Swing for a pure Windows desktop app

让人想犯罪 __ 提交于 2019-12-29 18:54:46
问题 I need to write a desktop app and its been a while since I started used Swing so will have a learning curve with either technology. Are there any advantages in doing my app using JavaFX 2? 回答1: 4 Years back I was having the same question and came to the conclusion that I would be best of using Swing since a lot of third party libraries were still written for Swing in those days. Also 1.0 releases from Sun were usually a bit rough around the edges (I burned myself on JSF 1.0 and JPA 1.0 :-).

Get selected row from TableView

て烟熏妆下的殇ゞ 提交于 2019-12-29 09:58:07
问题 I have a TableView configured as follows: tableView.getSelectionModel().setCellSelectionEnabled(true); tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); I can get the selected cells by calling tableView.getSelectionModel().getSelectedCells() I can get the selected items by calling tableView.getSelectionModel().getSelectedItems() Unfortunately, it seems there is no method like above to get the selected rows.. What I want to achive is a table configured to select cells but

TableView: Get Notified When Scroll Reaches Bottom/ Top of Table

二次信任 提交于 2019-12-29 09:40:09
问题 I can listen for scroll events: tableView.addEventFilter(javafx.scene.input.ScrollEvent.SCROLL, new EventHandler<javafx.scene.input.ScrollEvent>() { @Override public void handle(final javafx.scene.input.ScrollEvent scrollEvent) { System.out.println("Scrolled."); } }); But How can I be notified if the bottom/ top of the table is reached? 回答1: A simple way of doing this is to retrieve the ScrollBar using a lookup : ScrollBar tvScrollBar = (ScrollBar) tableView.lookup(".scroll-bar:vertical");

JavaFx: Adding TreeItem in TreeView again

一曲冷凌霜 提交于 2019-12-29 09:35:22
问题 I asked this question before [1]: JavaFx: Adding treeItem in Treeview but didn't get any response. Please I need help with this problem. A treeview in which user needs to add tree items. Here is my code import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx

Showing DoubleProperty up to two decimal places in TableView

让人想犯罪 __ 提交于 2019-12-29 09:26:31
问题 I'm having a problem showing a doubleProperty up until the second decimal. A rough layout looks like this: public static void main(String[] args) { private TableView<myType> myTable; private TableColumn<myType, Double> myCol; public class myObject { ..... DoubleProperty myDouble; .... public doubleProperty getPropertyMyDouble() { return myDouble; } public void setMyDouble(double d) { myDouble.set(d) } } And I fill the column with: ... myCol.setCellValueFactory(cellData ->cellData.getValue()

javafx animation looping

扶醉桌前 提交于 2019-12-29 09:23:11
问题 in c++ or c programming language, we know to change the cordinate we use gotoxy(x,y) and we can use looping and sleep to change the cordinate and making animation. like this; for(x = 20; x < 25; x++){ gotoxy(x,20); cout << "*" } but my queston is how about in JAVAFX 2.0 programming? i'm using netbeans 7.2. thanks for your any help. 回答1: Have look at using a Timeline Animation. It is a key component of animation in JavaFX and is used to establish when, and in what sequence, key parts of an

Multi-Threading error when binding a StringProperty

折月煮酒 提交于 2019-12-29 08:39:32
问题 I have a question about multi-threading and the binding of a StringProperty. I have a class CacheManager , which contains a Thread which updates my cache with the changes on the server. Now, I want to notify the user with a text and percentage of the progress (which are a Label and ProgressBar in JavaFX). I use public static DoubleProperty and StringProperty for this, which are defined in the CacheManager class. I just bind it like this: progressBar.progressProperty().bind(CacheManager

Java FX modifying UI component state with/without using Platform.runLater

a 夏天 提交于 2019-12-29 08:13:02
问题 In java fx controller i have two version of the code that simply sets a text on a label when a button is pressed (this is just a sample, but any other ui modification can be considered)... first version uses Platform.runLater : Platform.runLater(() -> { status.setText(""); statusIndicator.setVisible(false); }); the other one simply modifies it in ordinary thread : status.setText(""); statusIndicator.setVisible(false); Both are working perfectly fine, only difference i know so far is that