javafx-8

Datepicker in JavaFX 8

放肆的年华 提交于 2019-12-22 05:54:58
问题 Is there any implementation of Date Picker and Time Picker into the default JavaFX 8 package that I can use without using third party solutions? 回答1: DatePicker Yes, Java 8 has a DatePicker: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.DatePicker; import javafx.stage.Stage; import java.time.LocalDate; public class PickerDemo extends Application { @Override public void start(Stage stage) { final DatePicker datePicker = new DatePicker(LocalDate

How to rotate the LinearGradient in a given Shape?

落花浮王杯 提交于 2019-12-22 05:13:53
问题 I try to find the way to rotate the LinearGradient object nested into e.g. Rectangle object, say: Rectangle rect = new Rectangle(0, 0, 200, 200); LinearGradient lg = new LinearGradient(0, 0, 100, 0, false, CycleMethod.REPEAT, new Stop[] { new Stop(0, Color.BLACK); new Stop(0.5, Color.WHITE); new Stop(1, Color.BLACK); }); rect.setFill(lg); Now, I try to rotate this lg object, for example for 45 degrees to the left, but without rotating the whole rect . Is there any way to achieve that? 回答1:

where is the underscore in my CheckBox?

…衆ロ難τιáo~ 提交于 2019-12-22 04:59:10
问题 The shortest possible program to show my problem: import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class TestCheckBox extends Application { public static void main(String[] args) { launch(args); } public void start(Stage stage) {

javafx adding button to grid pane

青春壹個敷衍的年華 提交于 2019-12-22 00:29:22
问题 I am adding button to grid pane dynamically but after giving them function they all show same function and i don't knows why? import java.awt.Panel; import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.layout.GridPane; public class TestController implements Initializable { @FXML Panel mpanel; @FXML GridPane

Limit width size of Bar chart

泪湿孤枕 提交于 2019-12-22 00:28:26
问题 I created simple example of Bar Chart but I notices that size of the bar fits the chart. How I can limit the size? Foe example I would like to limit the width size. 回答1: As we already discussed here, to set a maximum width on every bar, we have to change either barGap or categoryGap accordingly, every time the scene or the chart are resized. The only difference from the refered question, is we have to resize the chart the first time is displayed. Based on the same code, let's create the

JavaFX printing non node objects

人走茶凉 提交于 2019-12-21 21:48:53
问题 I want to print a PDFFile object from the Pdf-Renderer library using javafx printing. Is it possible to print non Node objects? Currently i'm using AWT printing (check this example) but it doesn't go well with javafx because my javafx window freezes when the AWT print dialog comes up. Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.DEFAULT); PrinterJob job = PrinterJob.createPrinterJob(); if

Swing timer alternative for JavaFX and the thread management difference

不羁岁月 提交于 2019-12-21 20:39:50
问题 Is it safe to use Swing timer for JavaFX or there is an special alternative for Swing? What is the differnce of the thread management between JavaFX and Swing? In fact I'm interested to know the equivalents of Swing Timer , SwingUtilities.invokeLater() and invodeAndWait() for JavaFX. By the way what if we use some Swing components in the JavaFX? Should we use two parallel Timer/Threads for updating those components? 回答1: JavaFX equivalent of SwingUtilities.invokeLater() Platform.runLater(java

Migrate from Javafx2.2 to Javafx8

偶尔善良 提交于 2019-12-21 20:25:42
问题 I am trying to migrate Javafx2.2 application to Javafx8. I am getting following issue while using nested FXML : javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load. FXML file: <fx:root type="javafx.scene.layout.VBox" xmlns:fx="http://javafx.com/fxml" xmlns="http://javafx.com/javafx/8" fx:controller="com.ui.TestController"> <TextField fx:id="textField"/> <Button text="Click Me"/> </fx:root> Code: FXMLLoader loader = new FXMLLoader(); loader.setResources(bundle);

How to get a small ProgressBar in JavaFX

你。 提交于 2019-12-21 17:39:38
问题 I'm trying to get an iTunes like progress bar that is very small (height of about 5px) but I can't seem to go any lower than 19 or 20px. I tried setting -fx-max-height with no avail, also on the surrounding pane. Note that this value does indeed change the height - I just can't get it less than about 20px. Any ideas how to achieve that? I'd like to avoid using a plain rectangle for indicating progress because of loss of semantic and support of assistive technology. Thanks. 回答1: The

Export Stage into PDF

二次信任 提交于 2019-12-21 06:37:09
问题 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? 回答1: 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