I have to create the architecture shown in the image below.
The inner components can be created very easily but in which container I would place them is the question. BorderPane, AnchorPane, GridPane.. These cannot contain JFXPanel as achild node.
Hence , the task is to convert the swing panel into jfxpanel. So each element should be of javafx.
JFXPanel is for embedding JavaFX scenes inside a Swing application, which doesn't sound like what your are doing, so a JFXPanel is probably the wrong component type to use for your application.
I guess (and I could be wrong) that your application is a JavaFX application in which you would like to embed a Swing component - in which case you use a SwingNode.
JavaFX scene
- JavaFX layout pane root
- JavaFX ScrollPane
- SwingNode
- Swing component
In general, mixing JavaFX and Swing is not usually recommended.
I note that your question is tagged javafx-2, so note that SwingNode only exists from Java 8 on; i.e., it does not exist in Java 7, so there is no way to accomplish the structure you outline in your question within the context of Java 7 or JavaFX 2.2.
Related
i've been making simple javafx 2 gui application and found that prompttext in textfield of javafx 2 hides as soon as the textfield gets focus.
this wasn't this way some updates back.
prior to this update, the textfield showed the prompttext until some text is typed into.
this isn't good and really need a workaround for this.
I just solved this same issue by applying particular CSS rules to text inputs. Here's what I used (which should apply to all text-inputs)
.text-input, .text-input:focused { -fx-prompt-text-fill:darkgray; }
Erem Boto's answer is just fine and should solve your problem!
Please see my answer here to see how to solve the problem if you use proper Java code (no FXML and CSS file).
(And also how to get the other behavior back).
In short, this is the solution:
In case your application interface is written using proper Java code.
Java Code:
textField.setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");
Where textField is your TextField component.
And in case your application interface is written using FXML and CSS, add the following to your CSS file.
JavaFX FXML (CSS):
.text-input, .text-input:focused {
-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);
}
Can anyone explain the difference between VBoxBuilder and VBox in JavaFX?
VBoxBuilder boxBuilder = VBoxBuilder.create();
VBox vBox1 = new VBox();
Builders are added for convenience. They allow to create JavaFX nodes in one command without introducing new variable. It's more convenient in some situations.
Next two code snippets gives the same result, but latter doesn't create temp variable.
Without builder:
VBox vBox = new VBox();
vBox.setAlignment(Pos.CENTER);
vBox.getChildren().add(new Label("1"));
Scene scene = new Scene(vBox);
with builder:
Scene scene2 = new Scene(
VBoxBuilder.create().alignment(Pos.CENTER).children(new Label("1")).build());
N.B.: Although you may want to refrain from using builders as recently on open developers mail list an issue was raised which may lead to deprecating builders in the future releases: http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-March/006725.html
On builders and builder alternatives
Sergey's answer has this question covered, this is just some supplementary information.
There is a nice description of the builder functionality from one of the JavaFX builder creators in Advantages of JavaFX Builders.
However, as Sergey indicates, builders are deprecated from the core JavaFX platform. Oracle are busy removing all builder references from the JavaFX sample code.
Even though deprecated, builder functionality will be present and supported in JavaFX 8 (so for a long time to come).
Some alternatives to using the Java based JavaFX builders:
FXML can be used to provide a declarative syntax for development that is somewhat similar to builders.
JavaFX wrappers for other languages such as GroovyFX and ScalaFX provide builder style functionality as part of their core implementations by creating their own internal DSL for JavaFX object definition.
In Java Swing, there is JTree.linestyle property that enables/disables lines connecting the parent nodes in a tree to their children. Is there something similar in JavaFX 2? In all of the TreeView examples I've looked at for JavaFX, I haven't seen this. I also didn't see a CSS property to set.
JavaFX 2.2 does not have such a setting out of the box.
A feature request could be filed in the JavaFX issue tracker.
You may be able to achieve the line connection effect by creating custom TreeCell and TreeItem nodes and, on those, setting the treeCell.disclosureNodeProperty and the TreeItem graphicProperty as appropriate based upon the various settable event handlers for the TreeItem.
I'd like to display a UIWebView within a CCLayer for a Cocos2d 2.x project. I found the CCUIViewWrapper, but didn't get it to work with 2.x.
I don't really care about handling rotation and animation. I just wan't to display content from a web page on layer and also have a sprite to be able to go back to the previous scene.
Please help!
// Johan
If you don't want to use new version 2.0 features (I'm not using them myself at this point), then you can mix UIViews with Cocos by simply adding other views to your root view controller. After all, Cocos is itself a single view on the controller (if that's how you have it set up), and just add another view.
You can then easily tell the view controller to show the other UIViews by using the NSNotificationCenter, which I recommend in general over trying to communicate with the view controller from the Cocos layer.
In javafx 2.0 it is possible to create the layout by using FXML approach or by using normal java code.
What is the best way with respect to a well designed set of UIs. In my application there is about 100 sub UIs.
Thanks
FXML looks more logical for that purpose. By using FXML
you split business logic from view
you get option to edit design without recompiling project.
you get design as structured xml tree which is much easier to edit comparing to potentially randomly ordered java code
with SceneBuider tool you get an option to use visual editor for your fxml files
Get JavaFX Scenebuilder here.
FXForm2 is a library providing automatic JavaFX 2.0 form generation.
however FXForm2 is not full WYSIWYG GUI design tool.
http://dooapp.github.io/FXForm2/
Scene builder should be a good starting point to create unique UIs of your application. Considering you have 100s of UIs, I assume that some of their "appearances" should be identical with slightly different functions. You can load the FXML dynamically and assign controller at run time. Which means 1 FXML file can be used with multiple controllers. Which can save you some time while keeping the code dynamic for easier maintenance.
FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
loader.setController(new DBeditEntityUser());
So, to make use of the same FXML with a different controller.
FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
loader.setController(new DBeditEntityUserLevel());
Hope this helps.
fyi,
road map for Java fx http://javafx.com/roadmap/ shows that the scene builder will be released around middle of the year. From the above web page:
"JavaFX Scene Builder is a WYSIWYG GUI design tool for the
JavaFX platform. It enables designing user interface screens by simply
dragging and positioning GUI components from a palette onto a scene.
The tool generates files in FXML format2 that can be used within a project
in any IDE such as NetBeans or Eclipse. The JavaFX Scene Builder can be
used to create GUI for desktop applications and applets that run in a browser."