Scene Builder: How to hide borders on panels, etc - java

I'm just starting with Scene Builder and java. I've laid out my main GUI but when I preview it, it has wide borders for all my h/v boxes, anchor panels, etc. How do I hide the borders when I actually run (preview) my UI? Is there a way in scene builder (preferred) or will I have to code this instead?

Default border on layouts
There is NO default-border on layouts which can be visible. In case, you need to remove border from layouts you can set css code using setStyle() method,
yourPane.setStyle("-fx-border-width: 0px");
You can also use external css document for styling components.
Wide border on preview
Actually, the fxml preview means that showing your design in a window. So you might get confused with window frame border as shown in the below preview,
But you can make borderles- window by styling your stage using initStyle(),
primaryStage.initStyle(StageStyle.UNDECORATED);
You can also use TRANSPARENT style as well but you have to manage your title bar for customized-window.
(source: makery.ch)

Related

how to achieve resizability in javafx?

I have an AncharPane in which all components are placed/designed using Fxml but the problem is, when the frame resize all components are stick with its current position.
With AnchorPane, you can't get automatic resizing unless you have to resize your views one by one in the controller/code.
If you want autoresize, use BorderPane, VBox or HBox.
If you're using scene builder you can achieve this by selecting the component you'd like to make resizable, then go under layout and set the constraints.
You can also achieve this in your Controller class like this:
AnchorPane.setTopAnchor(yourTextField, 35);
AnchorPane.setLeftAnchor(yourTextField, 27);
AnchorPane.setRightAnchor(yourTextField, 120);
I used a TextField for this example, but you can do it with other components.
If the AnchorPane has a border and padding set, the offsets will be measured from the inside edge of those insets.
To autoresize I recommend BorderPane. You can also use VBox and HBox to organize you Scene.

How to remove thin back frame around pdf page at ICEpdf?

I'm making PDF displaying application with ICEpdf. I an trying to make some fancy layout according to good design practices. I use this code
System.getProperties().put("org.icepdf.core.views.background.color", "#FFFFFF");
System.getProperties().put("org.icepdf.core.views.page.border.color", "#FFFFFF");
System.getProperties().put("org.icepdf.core.views.page.shadow.color", "#FFFFFF");
To make background of viewer component white and to remove frame and shadow of the page. But the thin black frame around the page is still there:
Any chance to get rid of it? I want to acnieve illusion that pdf page is stretched to the size of parent container. I use swingNode inside JavaFX application (in case that have some importance).
Solved by wrappind PDF Swing component into AnchorPane and setting anchors to small negative values:
AnchorPane.setLeftAnchor(question, -5.0);
AnchorPane.setBottomAnchor(question, -5.0);
AnchorPane.setRightAnchor(question, -5.0);
AnchorPane.setTopAnchor(question, -5.0);

JavaFx-- positioning components in SceneBuilder

I used the drag and drop interface to put the components where I want them to be, but when the window is resized they lose their relative position. I have attached a screen shot of my hierarchy and of two windows to show how the components lose their position.
Hierarchy
Fullscreen
If you want to use the AnchorPane to layout your components, you can set the Anchor Pane Constraints, like in the image below:
This way it doesn't matter if you resize the screen, the button will always stay 10px far from the AnchorPane's right border.
When you use the AnchorPane to place components on screen you are not going to have a relative positioning, You should use others containers to layout your application. Read more about how to use Layout Panes here: Using Layout Panes
You need to study how to use Layout Panes. Dragging and dropping components results in absolute positioning, which really bad practice.

JavaFX 2 - ProgressIndicator overlay on a GridPane

In JavaFX 2 you can use a ProgressInidicator to show that some background task is in progress.
I would like to show ProgressIndicator centered on top of a GridPane, so that it overlays the GridPane. In Swing you can use GlassPane for this. How do I do it in JavaFX 2?
You can use StackPane. For info about layouts see Built-in Layout Panes.

How to add shadow to window in JavaFX?

I have removed the default borders around the primary stage:
stage.initStyle(StageStyle.UNDECORATED)
This removes the window borders which is what I want, but now I'd like to have a drop shadow under the window.
The top level BorderPane object has a dropshadow effect applied, but the shadow is cut off:
You can see the shadow slightly on the bottom right, but as soon as the main application area ends the shadow is cut off.
I created an example for this earlier. Use the specific revision linked as in later revisions I dropped the shadow effect from the dialog.
The sample places the stage content in a StackPane containing two panes. The shadow is only applied to the background Pane and the dialog content is placed in a top pane. The background of the top pane is slightly inset from the bottom pane so that the background and shadow can show through.
Further discussion is in a thread on displaying a shadow around an undecorated/transparent stage.

Categories

Resources