javaFX. How to set auto fill built-in module? [closed] - javafx

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
So, I have main frame start.fxml and opinion.fxml.
start.fxml - have "Button" item, and empty "AncorPane".
When I click on Button, in "StartController.java" execute:
#FXML
private AnchorPane ancorPaneMainFrame;
....
public void StatisticOpinion() {
try {
Node node = (Node) FXMLLoader.load(getClass().getResource("/StatisticsPackage/Opinion/opinion.fxml"));
ancorPaneMainFrame.getChildren().setAll(node);
} catch (IOException ioe) {
// logging ioe
}
}
That script is place opinion.fxml in AncorPane of start.fxml.
So, now I have problem with auto-resize opinion.fxml when I change size of start.fxml by mouse while programm is working.
opinion.fxml is not fill-out of parent AncorPane...

Assuming the AnchorPane is properly resized and node is resizeable you simply have to set the anchors:
Node node = (Node) FXMLLoader.load(getClass().getResource("/StatisticsPackage/Opinion/opinion.fxml"));
// set anchors
AnchorPane.setBottomAnchor(node, 0d);
AnchorPane.setTopAnchor(node, 0d);
AnchorPane.setLeftAnchor(node, 0d);
AnchorPane.setRightAnchor(node, 0d);
ancorPaneMainFrame.getChildren().setAll(node);

Related

Samsung Tizen.Net Wearable, How to control object font size dynamically [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
When using objects which contain text, such as a button or label, how can the text be dynamically sized in order to better keep text of different lengths within the viewable area?
For example if a Label within a Cell of a CircleListView of a CirclePage and the text becomes too long, it will easily fall out of view:
For context to what im looking for, in Android I am able to give an object either an autoSizeMinTextSize and/or autoSizeMaxTextSize tags which will automatically resize the font size based on the text length of the object.
This allows text of unknown lengths to be better kept on the screen.
How can this be done with in a Tizen.Net application, using CircularUI elements like Button or Label or with Xamarin.Forms in general?
After looking into this for a while I was able to learn of a few ways to resize text dynamically.
Take a center aligned Label:
PrimaryText = new Label
{
FontSize = _maxFontSize,
HorizontalTextAlignment = TextAlignment.Center,
};
Adding it to a Layout gives it access to the MeasureInvalidated event:
TextStack = new StackLayout
{
WidthRequest = _maxWidth,
Children = { PrimaryText }
};
Then when the text changes (among other things) the event will trigger where you can measuer the new text, compare it to the width of the stack, and then manipulate the size of font until the text fits within your layout:
TextStack.MeasureInvalidated += (sender, args) =>
{
var primaryMeasure = PrimaryText.Measure(PrimaryText.Width, PrimaryText.Height);
var stackMeasure = TextStack.Measure(TextStack.Width, TextStack.Height);
if (primaryMeasure.Request.Width > stackMeasure.Request.Width)
{
if (PrimaryText.FontSize <= _minFontSize)
PrimaryText.HorizontalTextAlignment = TextAlignment.Start;
else
{
var fontSize = PrimaryText.FontSize - 2;
if (fontSize < _minFontSize)
fontSize = _minFontSize;
PrimaryText.FontSize = fontSize;
}
}
};

Unity - Wait in MainMenu till Scene is completely loaded [duplicate]

This question already has answers here:
Objects in Scene dark after calling LoadScene/LoadLevel
(7 answers)
Closed 5 years ago.
I have a little problem with my main menu in Unity.
If I press the "Play" Button, it starts the game how I want it to.
The problem is, that my scene "Lights" are not completely loaded. (I have a lot of effects in it). So the scene is loaded, but everything is dark, completely without the lights:
I tried it with asynchronous "LoadSceneAsync", like so:
public void LoadByIndex(int sceneIndex) {
StartCoroutine(LoadNewScene(sceneIndex));
}
IEnumerator LoadNewScene(int sceneNumber) {
AsyncOperation async = SceneManager.LoadSceneAsync(sceneNumber);
while (!async.isDone) {
Debug.Log("hello");
yield return 0;
}
}
Ok i got it.
The problem was the Auto-Light-Baking.
Just go to Window > Lighting > Settings > Scene
And then scroll to the bottom and uncheck the "Auto Generate" for "Generate Lighting"

When full screen is applied in javaFx the controllers doesnt adjust to the screen

Im doing my 1st JavaFx project using scene builder 2.0. When I set the fullscreen method true, the anchor pane goes to full screen but the controllers inside the container doesn't adjust according to the adjusted pane size. It will be a great help if someone could point me out where I have messed up.
This is the code I have used in the main program.
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
javafx.geometry.Rectangle2D r = Screen.getPrimary().getBounds();
Scene scene = new Scene(root,r.getWidth(), r.getHeight());
String css = this.getClass().getResource("newCascadeStyleSheet.css").toExternalForm();
stage.setScene(scene);
scene.getStylesheets().add(css);
stage.show();
}
Ive set the sizes padding and everything using scene builder options.
Thanks in advance.
I think what you are missing is a Fit to parent setting in your view.
As you are using SceneBuilder, I suggest you to try the following: in the Hierarchy view (left side) right-click your component and select Fit to parent.
This is an example (taken from this awesome tutorial):

Resize a Button JavaFX

i have a question about a JavaFx Button.
In the following code i add a Button into a HBox.
ivTriangleImg.setFitHeight(16);
ivTriangleImg.setFitWidth(16);
ivTriangleImg.setRotate(iRotateCoord1);
btnTriangle.setGraphic(ivTriangleImg);
btnTriangle.setStyle("-fx-background-color:green;");
addComponentToBox(btnTriangle);
The Button gets a Graphic -> The Graphic is a transparent triangle with the Size of 16x16 pixels.
The Problem is, that the Button doesn't have the Size 16x16 it is so much more. How can i get the Button smaller and the Pictur must have the same size?
For JavaFX 8 use
btnTriangle.setPadding(Insets.EMPTY);
For JavaFX 2 use
btnTriangle.setStyle("-fx-padding: 0;");
However you can directly put the image view to the scene rather than setting it to the button's graphic, and add listeners you want:
ivTriangleImg.setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
// do something
}
});
I added your Code, it works very fine. I made it a little bit different:
btnTriangle.setStyle("-fx-background-color:transparent;-fx-padding:0;-fx-background-size:0;");

make a mp4 videos from pictures asp.net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to make a app in which user uploads pictures from their hard disc and then my app make a slide show of those pictures and after that the user is enables to download this in form of mp4 video . How can i do this ASP.NET ?
I found this Image sequence to video stream?
The accepted answer is detailed and feels really close to what you are asking for.
edit:
I found an example here: http://www.aforgenet.com/framework/docs/html/4ee1742c-44d3-b250-d6aa-90cd2d606611.htm
int width = 320;
int height = 240;
// create instance of video writer
var writer = new VideoFileWriter( );
// create new video file
writer.Open( "test.avi", width, height, 25, VideoCodec.MPEG4 );
// create a bitmap to save into the video file
var image = new Bitmap( width, height, PixelFormat.Format24bppRgb );
// write 1000 video frames
for ( int i = 0; i < 1000; i++ )
{
image.SetPixel( i % width, i % height, Color.Red );
writer.WriteVideoFrame( image );
}
writer.Close( );

Resources