Pane does not fit into the window - java

I am in the process of creating my first JavaFX application. I use SceneBuilder to design the GUI. I am facing the following problem:
I have dragged a Pane inside the GridPane. The Pane seems to have to follow the constraints given by RowConstraints and ColumnConstraints. The problem is that these are not aligned with my pane:
I did not expect this to be a big problem, but this results in a gap that is visible when I run my code:
I am talking about the white-colored part in this figure - I want this to be blue. Also, I want to see the entire pane in my window.
I played around and tried to figure this out on my own, but I don't see what I am doing wrong. Any ideas?

What seems to fix the issue is the following:
Inside the Inspector, open the Layout-entry for ColumConstraints. Change HGrow and HAlignment from INHERIT to ALWAYS and LEFT, respectively.
But if anyone knows more about this, feel free to post a separate answer!

Related

How can i launch a new pane in java FX immediately to the right of the previous pane within the same window/stage?

My goal is to have a program with 3 panes. A mulitfactor Auth. The first pane will have the user type in a passphrase, while the second pain will allow the user to pick a image from a drop down list. But I want the 3rd pane to launch just to the right of the 2nd pane after the use selects a image in the same "Main" stage.
Not looking for someone to code a program just point me in the right direction to what im trying to do. My searching skills are failing, either im not explaining it right or theres another word for this.
Edit:
This is my idea of how i want it to work. Now that i look at it using a border pane probably makes since, But im still stuck with, How can I launch each section of the border at a different time, i.e when something is clicked.
I would go about it by having 3 panes side by side and just blank for the first FXML file you load in. I would then have another FXML file with the same layout that contains what you want to show up in those panes.
Then with that, you can have the controller on request (like when a user hits submit or however you are wanting these to show up) grab the content inside of the pane on the second FXML file by ID and load it into the pane.
I've done something similar with changing anchor panes and keeping the toolbar from the original so I can add more on this when I get home and should be able to supply some code that is modified to fit your issue.
Edit 1: Sorry I was in a hurry to submit that dive I had to go but I am on mobile now so I can edit but not able to add a lot, just felt I needed to say, there are different options for what you can use to do this which is why I just said a pane instead of anything specific. Just wanted to submit something so you can start looking in the right direction till I am able to update.
Edit 2: Alright now that I am home I tried this out and was able to get this working. Here is how I did it.
So I had two FXML files. One with the 3 areas that you have your items, however, only the box that you want to show when it starts is shown. Each area is enclosed by an AnchorPane. I used the AnchorPane as a container so I can swap out what is inside of it. I then had a second FXML file that had all of the boxes you want to show all of which enclosed in AnchorPanes. Here are pictures explaining what I mean.
I have the first pane named initial.fxml and the second named grabfrom.fxml. For the pane names, I just have it as pane1, pane2, and pane3. Lastly, the methods I have are show2() and show3() and call them from the FXML when the respective buttons are clicked inside of the AnchorePanes.
With initial, I just load that up as normal from the start method in my main class and that is all that is needed to be done with that. We only had it so we could display something that does not have the boxes showing before needed.
Now for the important part
With what I have in show2(), which is called when the button inside of the first pane (which is there from the start) is pressed.
public void show2() throws IOException{
AnchorPane toSetPane2=(AnchorPane) FXMLLoader.load(getClass().getResource("grabfrom.fxml"));
toSetPane2=(AnchorPane) toSetPane2.lookup("#pane2");
pane2.getChildren().setAll(toSetPane2);
}
What this is doing is loading the grabfrom.fxml into a temp var that we cast to an anchor pane. (Do note that this works since as you can see in the screenshot the whole FXML file is an anchor pane. If you're not using it that way you can take out the casting and cast to something you are using or not even cast depending on what it is.)
It then set the var we just made to just the AnchorPane we need, which is the second one since that's the one we are adding. It does this with the .lookup("#ID"); method to get just the pane we need.
Lastly, it sets everything inside of the current pane2 to toSetPane2.
This could all be compressed down into one line, however, I have left it as is for easier reading.
You should be able to use this method of loading in a portion of your application for loading in the third one and for that matter any other parts you want to in any situation.
Edit 3:
Also as #Swatarianess had said, there are stackpanes, this method will work with anything that you can set an ID to so they would work just as well. I used AnchorPanes because I have done a fair bit with them and had some code I could recycle whilst making a test for it so it was easier. All you would do if you were using those though is just cast to a StackPane instead of an AnchorPane like this:
public void show2() throws IOException{
StackPane toSetPane2=(StackPane) FXMLLoader.load(getClass().getResource("grabfrom.fxml"));
toSetPane2=(StackPane) toSetPane2.lookup("#pane2");
pane2.getChildren().setAll(toSetPane2);
}
The transition between panes could be done with a stackpane.

Create filter window similar to excels when pulling data from ODBC connection

So I have been having some troubles with the code on how to create the filter window on the right. You may find a screenshot of the window I am attempting to recreate here:
Window Example
So the left handed part of the window which holds the columns chosen is working perfectly. However, I can't figure out how to code the container for the right window. I have attempted a JScrollPane, but failed to add the text boxes correctly. It kept trying to make me add them as headers, rows, the main field, and more. I then tried adding a JPanel to the main JPanel holding the whole window, but I am unable to figure out how to add a scroll bar to the filter JPanel as well as looking on google for the answer.
The reason for the scroll bar is because I plan on adding more filter options than the window will allow. So the container that will be used for the filter options will need to be scrollable to allow for those additional filter options to be used.
I hope that this helps. I am not partial to any specific solution as I honestly don't know which one will fulfill what I am looking to do. I hope was able to provide enough detail. I am unable to provide code at this point as I am not near the project and there is so much code to show. If any clarity is needed, I will definitely do so. Thanks for any help/advice.

Superimposed node in javafx

Maybe the title of my question is not good but actually I don't know how to name it.
So I will try to explain my problem really clearly.
So I want to know if its possible to make like a "ErrorBar" inside my scene. I understand by this to show this element over other node inside the scene for a short time.
I have a BorderPane and I want when I have an error in my application (like webservice error) to show the error to the user. And for that I want to move a gridpane from the right to the left of the screen without change my scene (like put this object in the top of the borderpane).
I don't have any example with a software who do it but I think some stuff in Javascript can do something like this. Just show a green or red bar in the top of the website event it's somthing already show.
If someone know how to do that it will be great.
Actually I use Java 8 latest version.
Feel free to ask more if you want to know more about my question.
Thanks in advance.
Fische
I think you can just use a StackPane which allows you to work with "layers". Indeed in the StackPane, each Node you add to it becomes a "layer" and appears above previously added Nodes. Meaning that the latest Node will always be on top.
Knowing that, you can add your error message to the StackPane and then, if you use a transition to move it, at the end of the transition you automatically remove the message from the StackPane.
Hope it helps.

Is there a way to ailgn a MigLayout column to another JPanel's inner component?

I'm trying to align the 'third' column to the 'browse' button inside the panel above (whose layout is also a MigLayout). Hadn't found any command to do it, then tried to align it manually (using the windowbuilder plugin for Eclipse), as displayed in the image below, but the final result just isn't the same as it looked in the windowbuilder editor (second image). Anyone knows why, or knows a command to solve this issue? Thanks
windowbuilder screen image
application image
EDIT:
Solved the manual alignment by deleting the first two columns (column 0 and 1.. it seems since they didnt have a preferred width they were causing some interference - don't know how exactly - on the following columns)
Though I'd really prefer to do that by using an expression/command of some kind to align a columns with the 'x' position of a component, as I said before .. =. If anyone knows of a better solution I'd really like to know =]
Thanks!

Netbeans! Components moved from design to runtime

Things look one way in the design area, but are re-sizing moving around.
It does this with every LAF, its not a style issue, its creating large empty spaces where there are none on the design area.
Any ideas?
Sorry I can't post pictures, I created the profile to ask this question
What am I doing to cause this discrepancy and how can I fix it?
You might try changing the panel layout. Right click a jPanel -> set Layout -> grid bag or one of the others. I've had a lot better luck with GridBag than with Free Design. Then you can go right click-> Customize Layout to customise
As for what you're doing on your installation that might cause this, I'm afraid I can't say.

Categories

Resources