What I'm trying to do is to scale a popup content of a javafx.scene.control.DatePicker using javafx.scene.control.skin.DatePickerSkin to add an scale,
DatePickerSkin skin = new DatePickerSkin(datePickerFrom);
skin.getPopupContent().getTransforms().add(new Scale(1.5,1.5,0,0));
By using this code, all I got is
I didn't found a way to input a skin instead of DatePicker and if there is a way to add a scale directly to the Datepicker
In this software, all items are getting scaled for the display sizes
in case you wanted the detailed code, I created this,
Stage stage = new Stage();
DatePicker datePicker = new DatePicker();
DatePickerSkin datePickerSkin = new DatePickerSkin(datePicker);
datePickerSkin.getPopupContent().getTransforms().add(new Scale(1.5,1.5,0,0));
Pane pane = new Pane();
stage.setWidth(300);
stage.setHeight(100);
pane.getChildren().addAll(datePicker);
Scene scene = new Scene(pane);
stage.setScene(scene);
stage.show();
Related
How to make such a settings panel so that you can see the scene with 3d figures as in the picture?
my scene is under the panel.
I create a BorderPane,
And she completely closes the scene.
My code is in the second picture, but I don’t know how to make the scene visible
RadioButton rdoEasy = new RadioButton("Easy");
RadioButton rdoMedium = new RadioButton("Medium");
RadioButton rdoHard = new RadioButton("Hard");
var groupDifficulty = new ToggleGroup();
groupDifficulty.getToggles().addAll(
rdoEasy,
rdoMedium,
rdoHard
);
ToolBar toolBar = new ToolBar();
toolBar.setOrientation(Orientation.VERTICAL);
toolBar.getItems().addAll(
new Separator(),
rdoEasy,
rdoMedium,
rdoHard,
new Separator()
);
BorderPane borderPane = new BorderPane();
borderPane.setLeft(toolBar);
borderPane.setCenter(group);
borderPane.getCenter();
Scene scene = new Scene(borderPane, orgSceneX, orgSceneY,true,SceneAntialiasing.BALANCED);
I'm working on a school project in Java FX, I'd like to add an icon next to my primarystage title and center the title, just like the one in the picture. I have looked around in the javadoc for Stage but i can only find the setTitle() method. Here is a link to what i'd like to do :
You can set your stage to undecorated, set your scene root to a border pane and create your own custom top bar.
BorderPane root = new BorderPane();
root.setTop(new Pane(bb, label));
Scene scene = new Scene(root, 400, 400);
ButtonBar topBar = new ButtonBar(… insert buttons in here....);
// eg: Button b = new Button("X); b.setOnAction(e->{stage.close();});
root.setTop(topBar);
stage.initStyle(StageStyle.UNDECORATED);
Just wondering if anyone know how to implement a vertical scrollbar that spans the entire scene in JavaFX? Been trying to figure it out for a few days now and I just can't seem to figure it out.
If you mean make it your root you can do it like this
Stage stage = new Stage();
ScrollPane pane = new ScrollPane();
TextField yourcontent = new TextField("this is an example");
pane.setContent(yourcontent);
pane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
Scene scene = new Scene(pane,300,300);
stage.setScene(scene);
stage.showAndWait();
and then put the rest of your content in it via setContent();
I have a titled pane, and I'm displaying an image in this pane, but the image is very big so I resize it, to fit the pane. Since the image becomes smaller, the user might want to view it in original size, so I implemented a method on mouse click opening the original image in new bigger window.
imgViewPicture.setFitWidth(titledPanePicture.getPrefWidth());
imgViewPicture.setPreserveRatio(true);
imgViewPicture.setSmooth(true);
imgViewPicture.setCache(true);
titledPanePicture.setContent(imgViewPicture);
The problem is, when I click on titledPanePicture the small image disappears, its content is cleared. Why? For the solution I added a reloading of the content on mouseclick event. But I dont like it, I think the content should stay the same for titledPanePicture.
Here is my mouseclick event:
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
Group root = new Group();
Scene scene = new Scene(root);
scene.setFill(Color.BLACK);
HBox box = new HBox();
imgViewPicture.setFitWidth(0);
box.getChildren().add(imgViewPicture);
root.getChildren().add(box); // before tPane
stage.setTitle("Picture Original Size");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
reloadContentofTitledPane(); // This line is the fix but I find it unnecessary
Tips would be appreciated.
You seem to use the same ImageView in both scenes. However a Node can only be placed at a single place in a single scene graph.
Create a new node for your new Scene.
ImageView newImageView = new ImageView(imgViewPicture.getImage());
...
box.getChildren().add(newImageView);
I am using JavaFX 2 in Netbeans. How do I get the width and height of an element to adjust when the Frame is resized? Here is my layout:
Stage stage = new Stage();
stage.setTitle("Hello World");
final Group root = new Group();
Scene scene = new Scene(root);
BorderPane border = new BorderPane();
border.setPrefWidth(stage.getWidth());
border.setPrefHeight(stage.getHeight());
HBox outerHBox = new HBox();
border.setCenter(outerHBox);
root.getChildren().add(border);
stage.setScene(scene);
After some more research
I found where this has been done before http://java.dzone.com/articles/setting-stage-javafx-sdk but it is in an older FX (very different from JavaFX 2). I am having trouble translating it. Looks like I should be using binding? I've never used binding before and I've barely used FX.
Whats the best way to accomplish this?
Not all Node classes enable resizing. The Group class is one of these. You'll understand this when calling isResizable() on your root object. Use instead a subclass of Region e.g. BorderPane as your root.
Stage stage = new Stage();
stage.setTitle("Hello World");
final BorderPane border = new BorderPane();
Scene scene = new Scene(border);
Button button = new Button("test");
HBox outerHBox = new HBox();
outerHBox.getChildren().add(button);
outerHBox.setAlignment(Pos.CENTER);
border.setCenter(outerHBox);
stage.setScene(scene);
Your example should work, now.