javafx-8

JavaFX 8 Custom ListView Cells it's Evil

﹥>﹥吖頭↗ 提交于 2019-12-04 03:15:48
I have custom ListView cell i have HBox with two controls: Label with name field It's must generated from context of object For example i set ListView items array of Class Fields, if field type Boolean i create CheckBox, if String i create TextField and etc. Problem is: i get Field object only in method updateItem() - and only there i can create my controls. In JavaFX 7 all works fine, but on Java 8 - i dont see my controls. Is exists correct way to resolve my case? UPDATE 1 Here complete example for replicate problem: package javafx8listviewexample; import java.lang.reflect.Field; import java

FXML Variables not binding

Deadly 提交于 2019-12-04 02:38:55
问题 I am having an issue with my FXML injection. I have setup my program as far as I can tell but it seems that I am missing something. My code is below: Main: package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; public class Main extends Application { @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader

Creating a row index column in JavaFX

扶醉桌前 提交于 2019-12-04 02:35:01
问题 I have a JavaFX TableView that I'm populating with an ObservableList of Tasks. I've been trying to create a column that displays the index of each row, which serves as the ID for the tasks in the table, but I've tried the method here and similar methods from other sources with little success. My code for reference, which has no superficial errors (as far as Eclipse can tell): @FXML private TableColumn<Task, String> taskIndexCol; Callback<TableColumn<Task, String>, TableCell<Task, String>> cb

JavaFX default focused button in Alert Dialog

こ雲淡風輕ζ 提交于 2019-12-04 00:13:31
Since jdk 8u40, I'm using the new javafx.scene.control.Alert API to display a confirmation dialog. In the example below, "Yes" button is focused by default instead of "No" button: public boolean showConfirmDialog(String title, String header, String content, AlertType alertType) { final Alert alert = new Alert(alertType); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); final Optional<ButtonType> result = alert.showAndWait(); return result.get() == ButtonType.YES; }

JavaFX 8 - How to bind TextField text property to TableView integer property

无人久伴 提交于 2019-12-03 23:41:19
Let's say I have a situation like this: I have a TableView (tableAuthors) with two TableColumns (Id and Name). This is the AuthorProps POJO which is used by TableView : import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; public class AuthorProps { private final SimpleIntegerProperty authorsId; private final SimpleStringProperty authorsName; public AuthorProps(int authorsId, String authorsName) { this.authorsId = new SimpleIntegerProperty(authorsId); this.authorsName = new SimpleStringProperty( authorsName); } public int getAuthorsId() { return

Changing javafx button color on click?

拥有回忆 提交于 2019-12-03 23:05:13
问题 I know I can set a color by using the pressed pseudo selector: myButton:pressed{} Problem is, im trying to do this in code by overriding the css background color from my stylesheet by doing: myButton.setStyle("fx-background-color: #FFF"); The latter fails do change the color though. Could it be that once ive set my stylesheet that I cant override it? How can I change the button color on click? 回答1: I had to do a similar thing(here is simplified, there is just the part of code which change the

Export Stage into PDF

坚强是说给别人听的谎言 提交于 2019-12-03 21:40:00
IS there any way to export Stage or some other component like BorderPane with visual components into PDF file? I want when I click a button to export the component into PDF file? IS there any example? you can send a node to a printer and save it as pdf with a virtual printer public class PrinterNodetExample extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button(); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() {

Display additional values in Pie chart

二次信任 提交于 2019-12-03 20:28:07
问题 I have this example of Pie chart data: import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.chart.PieChart; import javafx.scene.chart.PieChart.Data; import javafx.scene.control.ContextMenu; import javafx.scene.control.Label;

How to click a button on website loaded into JavaFX Webengine

给你一囗甜甜゛ 提交于 2019-12-03 16:20:34
I am pretty new to JavaFX. I have successfully loaded a website into my JavaFX application. I would like to log in to the website from my java application. So far I am able to insert my login values to the appropriate input box, but I cannot figure out how to click submit button. Can Someone help me. Here is what I have so far. Here is my controller class. public class Controller implements Initializable{ @FXML protected TextField usernameLogin; @FXML protected TextField passwordLogin; @FXML protected Button loginButton; @FXML protected WebView webviewBrowser; @Override public void initialize

JavaFX TableView Edit with single click and auto insert row?

柔情痞子 提交于 2019-12-03 16:11:45
I used tableview in my program to display few rows it was good . my program is used for accounting and as you know there is alot of data insertion in it and i used the table view and i faced a lot of problem :. problem 1 : when the user want to modify a value he will double click to get edit the cell i want my user to select any row and start typing . problem 2 : in my program the user may insert 100 row for a day of work i need a strategy to adding row automatically for example when he insert row it should add an empty row under the current row to complete his data entry easily . please help