New to JavaFX. Confused. How can I align my objects?
I've been playing with JavaFX and I really like it. But I can't seem to get my content where I want. Even if I place a vbox on the CENTER and a label on TOP, they are always in the Center and almost touch each other.I want to have:
My title
Sublabel
Button1
Button2
Button3
BottomLabel
But it appears as:
My title
Sublabel
Button1
Button2
Button3
BottomLabel
If I have settranslateX my vbox or label superior, he moves from the label, but moves also everything else with it.
How can I to align properly?
Here's my pseudo code:
PreMenu() private node
{
Group group2 = new Group();
Component BorderPane = new BorderPane();
Text label = new text ("Please choose an Option");
label.setFont (make ("Kozuka Gothic Pro", 30));
label.setEffect (addEffect (Color.web ("#FF6600"),.85, 20));
label.setTextAlignment (TextAlignment.CENTER);
label.setTranslateY(-300); This moves my label, but it also moves the vbox below down.
VBox, vbox = new VBox();
Option1 button = new Button ("Firstbutton");
Option2 button = new Button ("Secondbutton");
Option3 button = new Button ("HelpButton");
option1.setEffect (addEffect (Color.Web ("#FF6600"),.8, 10));
option2.setEffect (addEffect (Color.Web ("#FF6600"),.8, 10));
Option3.setEffect (addEffect (Color.Web ("#FF6600"),.8, 10));
option1.setTextAlignment (TextAlignment.Center);
option1.setMinWidth (400);
option2.setTextAlignment (TextAlignment.Center);
option2.setMinWidth (400);
Option3.setTextAlignment (TextAlignment.Center);
Option3.setMinWidth (400);
vbox.setSpacing (20);
vbox.getChildren () .add (option1);
vbox.getChildren () .add (option2);
vbox.getChildren () .add (option3);
pane.setTop (label);
pane.setCenter (vbox);
Group2.GetChildren (). Add (NCA);
return group2;
}
Do not wrap a group around your content, group is used for special cases and is not a general container to keep your knots together. In addition, you must set the correct alignment on the VBox. Here's a working example:
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
public class AlignmentTest extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
BorderPane pane = new BorderPane();
pane.setStyle("-fx-background-color: red");
Text label = new Text("Please Choose a Option");
label.setFont(Font.font("Arial", 30));
label.setTextAlignment(TextAlignment.CENTER);
VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);
Button option1 = new Button("Firstbutton");
Button option2 = new Button("Secondbutton");
Button option3 = new Button("HelpButton");
option1.setTextAlignment(TextAlignment.CENTER);
option1.setMinWidth(400);
option2.setTextAlignment(TextAlignment.CENTER);
option2.setMinWidth(400);
option3.setTextAlignment(TextAlignment.CENTER);
option3.setMinWidth(400);
vbox.setSpacing(20);
vbox.getChildren().add(option1);
vbox.getChildren().add(option2);
vbox.getChildren().add(option3);
pane.setTop(label);
pane.setCenter(vbox);
Scene scene = new Scene(pane, 600, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
}
In addition, read the post post-it on the way to view the code :)
Tags: Java
Similar Questions
-
have xp backup file of the old pc would like to put on new pc with vista, how can I do?
have xp backup file of the old pc would like to put on new pc with vista, how can I do?
Vista backup and restore tools are distinguished by the backup program provided with Windows XP and if the backup files would be incompatible.
Perhaps you should look at is:
http://Windows.Microsoft.com/en-us/Windows-Vista/demo-transferring-files-and-settings-from-another-computer
You can transfer files and settings from one Windows computer to another by using a calledWindows Easy Transfer tool. To use this tool, your computer must be runningWindows 2000, Windows XP or Windows Vista, and your new computer must be Vista runningWindows.Harold Horne / TaurArian [MVP] 2005-2011. The information has been provided * being * with no guarantee or warranty.
-
I changed my internet provider and so I have the new email address. How can I delete my old e-mail address and put them in a new in Outlook express? AND another problem, if I want to send pictures by e-mail... default .it my no more used by email, not allowing to send because I do not agree with them. Thank you
original title: outlook express
XP was the last version of Windows to use Outlook Express and that you are in a forum of Vista. Assuming that Windows Mail:Tools | Accounts and add the new address/provider and remove the old.Windows Mail: Setting up an account of end-to-end
http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-mail-setting-up-an-account-from-start-to-finishOnce the old account is removed, your second issue must be without object. -
Where are the files stored WindowsLiveMail? Under what article directory. I have "tons" of e-mail messages stored on the old disk and need to move them to the new drive faster. How can I do?
The location of the store folder, which contains all the messages, calendars and the account settings, is configurable by the user. The default location is
C:\Users\{user}\AppData\Local\Microsoft\Windows Live MailIf the installer of WLMail is a record storage in the default location, it normally acknowledge and take into use if. The only user that would be required should reinstate saved passwords. If this is to succeed, the old and new installations of WLMail normally must be exactly the same construction. The storage location must be in place in the default location on the new drive before installing WLMail. Also, the current user must be the owner of the record store to its new location.
If the old drive is installed on the same computer as the new facility in WLMail, you can point the Import Wizard to import messages to the old folder of the store. They will find under storage folders into imported folders.
-
I just installed my copy of cs5 in a new computer windows 10 - How can I get it to recognize my NEF files, as it did in my old laptop?
Could you please install the DNG Converter, and then it should help
Installation link: Adobe - Adobe Camera Raw and DNG Converter: for Windows
-
Followed by my previous inquiry, my hard drive crashed and lost my copy of Acrobat 9 in the installation of the new hard drive. How can I go to re - install Acrobat 9 from the disc, I hold. Thank you, Don Hamilton
Just reinstall from the disc (or download it from https://helpx.adobe.com/acrobat/kb/acrobat-8-9-product-downloads.html) and activate it with your serial number.
If your number of activations exceeds max (2), then you will need to contact customer service.
-
How can I customize the object of a hyperlink email
How can I customize the object of a hyperlink email? I added a hyperlink to an image. I want to click, a new message of pop e-mail filled up with a topic already personalized.
hyperlink would be
topic of mailto:youremailaddress?subject=email here
-
How can I make java objects in a schema
Hello.. good afternoon everyone...
How can I make java objects from a database schema?
Assume that the credentials are scott/tiger@db1
One other thing is that... I do cmd (command prompt) because there is no developer plsql or sqldeveloper installed in the machine.
PLSS help... Thanks in advance...Hello
That's ok. This run just to tryDROP JAVA SOURCE "javaclass1";
Kind regards
Simma... -
I can download e-mail from the server to the new email address, I just added to Thunderbird. But the new address appears at the bottom of the address list that is located on the left side of the window of Thunderbird. How can I move it upward?
Also, I did something that made a padlock icon appears on top the the email envelope icon. How can I remove it? Thank you.
Go to add ons page and sort for manual sorting folder. It allows you to reorganize the folders pane.
The lock icon indicates that this account uses a secure connection. You don't want to remove it.
-
My e-mail folders have disappeared since the 'change'. How can I fix this? Top of the entire page is also different with nothing as if it was. Bad news. Do not like. The use of Mozilla Firefox.
Which site of e-mail do you use? If it is a popular (for example, Yahoo, Hotmail, Outlook.com, Gmail) volunteer could take a look and see how to change the page layout. If it is dark, you might need support on the site.
-
6.0 interface is confusing; How can I make it look like the previous one?
How can I cause the tabs and buttons to be where they were on older versions? I tried to get used to the 'new' interface, but I spend so much time looking for things that I used to know exactly where they are. How can I get the old version back, or how I can cause it to put things where they are supposed to be?
The feet must be on the bottom, just above the display of the web page. And what happened to the little arrow on the back button that would allow me to return to the previous page? And why the hell did you put the 'Cancel' button where it is? No sense to me.
Gimme back the old interface.
Or if I should abandon Firefox?
Jan SmithThe arrow to open the history tab of the previous buttons and following was removed in Firefox 4 and later versions.
Use one of the following methods to open the tab history list:
- Right-click on the back or next button
- Press and hold the left button of the mouse on the active back or forward button until the list opens
You can watch this extension:
- Backward forward history Dropdown: https://addons.mozilla.org/firefox/addon/backforedrop/
-
I have an Acer Aspire TimelineX 1830 t-68U118. The original hard drive died, so I replaced it with a new hard drive. I loaded Windows 7 x 64 and loaded the chipset drivers and the network drivers. The laptop is always my bluetooth equipment (even if I loaded the drivers Atheros). Does anyone else have this problem? How can I get the bluetooth to work?
It would probably depend on the status of the warranty of the system.
You must contact the service for options.
-
I need a new hard drive. How can I reload windows?
I had a SMART failure had predicted the message of hard drive on my laptop. If I have to get a new hard drive, how can I reload windows? I have not all discs with my computer, but I have a product key,
Hello SNQQPYSALS,
You have a few choices:
1. contact your computer manufacturer and ask them to send a set of recovery DVDs.
They do it for a small fee.
2 borrow a Microsoft Vista DVD from a friend, etc. (NOT a recovery DVDs) Microsoft DVD will contain all versions of Vista.
This is your product key that determines which version is installed.
Just make sure you take the correct 32-bit or 64-bit DVD in Vista 'bit' come on 2 different DVDs.
3. IF your hard drive is still working, make a game of the recovery before it completely Partition recovery DVDs fails.
The manufacturer will tell you how.
-
I recently got a new laptop and I need to transfer my files to my computer windows vista to windows 7, but I need to remove the transfer windows easy off vista to install the new Windows 7... How can I do this. its driving me crazy
You cannot remove the Windows program like that... Windows 7 easy transfer to restore.
-
Ok. Here goes. My new printer is a HP Officejet 4622. It prints everything horizontally. How can I stop this? The operating system I have is Windows 7. Received an error message and no changes. It is implemented for eprint. Does make a difference? Thank you
Hello
The problem could be that the print settings could be changed to landscape. Change the setting to portrait and then try to print again.
To change the settings:
Right click on the printer > Printer preferences > Layout > select the Portrait Orientation > Apply
Maybe you are looking for
-
Remove the newly opened tab tiles
When I open a new tab, it was always empty in the past. With FF 13 the new page is full of thumbnails of the latest web pages. How can I get rid of them. My home page is empty and I want to also empty tabs.
-
I had a problem, which lead to the other. I'll just show what I posted in the other thread. Thus, I have provided the link for reference. This is the excerpt from this thread: http://social.answers.microsoft.com/Forums/en/vistawu/thread/a42818dc-4037
-
I have a movie that has a voice language 2 English and french, I want to delete language vocal french film, is possible to do with the audacity program and how?
-
BlackBerry Smartphones end call (red button) broken - need alternative
I actually gave up trying to fix it. In fact, I'm looking the other way end a call. Is there any application that allows callers to terminate a call of the touchscreen? I looked and I've not found anything (obviously). Please notify. H.