Gluon Scene Builder Freezes - javafx

I'm configuring the style of my form that I want to change its background color, in the JavaFX CSS section there was 2 textfield; one for the tag(eg. -fx-border-color) and the other is the value in it. Everytime after I inputted the first textfield I began to switch to the value textfield but the scene builder suddenly freezes. I checked it on my task manager but I found it that it doesn't consume cpu and its instance is still there. What could be the problem?

I had the same issue of the Scene Builder freezing when adding a Tab element to a TabPane etc, and first Running the SceneBuilder application as an Administrator and manually opening the the .fxml file from the Scene Builder has solved this issue. This might not be a permanent fix, but it will be a temporary workaround.

Related

JavaFX Scenebuilder: TextArea and TextField change font

for Labels I can change the font easily, but there is not option for TextFields and TextAreas. Is this normal?
Can't I change the font in the scene builder for these object types?
Yes, you can change the font for a TextArea or a TextField from Scene Builder; it's done the same way as for a Label. Here's a screenshot for TextArea:
Make sure you are using the latest version of Scene Builder. Downloads can be found here. Note that Scene Builder is maintained by Gluon (for a while now), not Oracle.

javafx scene builder setting accelerator sets the hot key as "N" instead of "ALT+N" for new menu item under the file menu of a text editor

I am creating a text editor using the gluon scene builder with java fx. The scene builder version is SceneBuilder-10.0.0 used with java version "10.0.1". I have a project to build a Text Editor. While building the components in the scene builder, under the File menu, I have the following menu items: New, Open, Save, Save As, and Close. I am trying to set the shortcut keys in the scene builder itself. There is an option to set the accelerator (under the Inspector Panel, in Properties) with a key. However, when I am setting it for the new menu item (and other menu items), it is set as this ignore ALT+N (Please click on the link to see the image) which makes the short cut key in the text editor to only "N" and not "ALT+N". I tried to code it in the controller class also with setAccelerator(), still it gives me similar results. I even donwloaded a fresh version of the scene builder and still does not work as expected. How can I get the short cut key to be as:
New ALT+N
under the new menu item, instead of the current:
New N

JavaFX Scenebuilder: How to connect pages with each other?

I am working on a JavaFX project and the problem that I am facing is that I can't connect the different pages for my application. I can't go from another FXML file to another FXML File. For example I have two FXML Files. One for the Login Screen and one for the Menu. What I want is that when I click on the login button of my Login screen that I immediately go to my Menu Screen.
One way to transition from one screen to another is to assign a new Scene to a Stage using the setScene method of Stage.
Another way is to assign a root node like BorderPane to the Scene and swap FXML using its set methods(setTop, setCenter etc.) as per your application needs (In your case, on logging in).

how to bind scene with stage in javafx2

Actually I want to switch from one scene to another scene on particular event. So i can do that by setting scene of the stage without binding but i want to bind my stage with scene as soon as a flag changes my scene will change automatically....pls help
The JavaFX Demos and Samples Downloads contains an application called FXML-LoginDemo. It demonstrates how to change scenes in a stage. The important part happens in the method replaceSceneContent. As for automatically changing the stage when a flag in your application is updated, there are several ways to do that. I recommend using a PropertyChangeListener or using JavaFX withCDI and then using CDI events. I used the latter approach in my application and it works really well.

Make a javafx stage the owner of a JDialog?

Display a swings JDialog containing a JRViewer for Jasper Report, from within a javafx application menu item click. BUT the JDialog is not MODAL even after setModal(true) as it is not owned by javafx stage. How to make a javafx stage the owner of a JDialog? Alternatively how to display a Jasper report inside a javafx stage, scene?
Don't use a JDialog. In JavaFX you use Stages. Put your Jasper report inside a Scene, put the Scene in a Stage. I think you can't put Swing components inside JavaFX components, so you must check this link: Integrating JavaFX into Swing Applications
Code to make a JavaFX dialog:
Stage stage = new Stage();
stage.setTitle("Title");
stage.setResizable(false);
stage.initModality(Modality.APPLICATION_MODAL);
stage.initOwner(primaryStage);
stage.initStyle(StageStyle.UTILITY);
(...)
Scene scene = new Scene(...);
stage.setScene(scene);
In the code above the Stage will behave exactly like a dialog.
Also check this:
How to create a JavaFX dialog?
Hello World, JavaFX Style
Back to the first (base) question: It's not possible to make a Stage the owner of a JDialog. But, after setting the content of the SwingNode
swingNode.setContent(xxx);
you can get the parent of xxx (may be the parent of the parent of xxx too...) until you find a (AWT-) Frame or (AWT-) Dialog. In the case of SwingNode it's a JLightweightFrame. This object you can use as the owner to create your JDialog.
But, I think there is a bug in the JavaFX SwingNode mechanism. The JDialog appears functionally modal, if you set it modal (setModal(true)), but it may appear behind the main (JavaFX) window. It's still possible to move the main window, to bring it in front and so on, what should not be possible if there is a modal dialog. But this is another topic.
To view a Jasper Report in javafx ( jdk 1.8> ) stage
JasperPrint jp = JasperFillManager.fillReport(reportsource, params,getCon());
SwingNode swingNode = new SwingNode();
swingNode.setContent(new JRViewer(jp));
AnchorPane anchorPane = new AnchorPane();
AnchorPane.setTopAnchor(swingNode,0.0);
AnchorPane.setBottomAnchor(swingNode,0.0);
AnchorPane.setLeftAnchor(swingNode,0.0);
AnchorPane.setRightAnchor(swingNode,0.0);
anchorPane.getChildren().add(swingNode);
Scene scene = new Scene(anchorPane);
Stage stage = new Stage();
stage.setHeight(550);
stage.setWidth(600);
stage.setAlwaysOnTop(true);
stage.setScene(scene);
stage.showAndWait();
Alternatively how to display a Jasper report inside a javafx stage, scene?
Output HTML from your Jasper report and load the report in a JavaFX WebView.
Make a javafx stage the owner of a JDialog?
I don't think this is possible. What should work instead is to make your application a Swing application and host your JavaFX content inside a JFXPanel inside a Swing JFrame. Then you have no Stage and the owner of the JDialog can be the JFrame hosting the JFXPanel.
now it's possible to do that
what you need now is install jdk 8
because swing content in javafx is introduced in jdk8
#FXML
private SwingNode swingNode;
...
JasperPrint jasperPrint = JasperFillManager.fillReport(FileName, hash, connect);
swingNode.setContent(new JRViewer(jasperPrint));
oracle just add tutorial for this too
for the next you can follow this link
oracle tutorial embed swing in javaFX
I have written a JasperReports print preview stage class in JavaFX 8. It is a pure JavaFX code and there is no need for use of SwingNode class.
In comparison to the JRViewer it does not support links and parts, but print preview window does not need it anyway. On the other side, code is much, much shorter and therefore it is easy to understand and to adopt further to everyone's needs.
Source code for this class is freely available at GitHub repository.

Resources