There is an unexplained space between buttonsDifferences between HashMap and Hashtable?What is the difference between public, protected, package-private and private in Java?What's the difference between SoftReference and WeakReference in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()What is the difference between JDK and JRE?What is the difference between JSF, Servlet and JSP?Difference between HashMap, LinkedHashMap and TreeMapWhat's the difference between @Component, @Repository & @Service annotations in Spring?What is the difference between canonical name, simple name and class name in Java Class?
Does "Software Updater" only update software installed using apt, or also software installed using snap?
Is there any way to adjust the damage type of the Eldritch Blast cantrip so that it does fire damage?
Re-testing of regression test bug fixes or re-run regression tests?
What is this old US Air Force plane?
is it correct to say "When it started to rain, I was in the open air."
Why does lemon juice reduce the "fish" odor of sea food — specifically fish?
Is Valonqar prophecy unfulfilled?
Motorola 6845 and bitwise graphics
Why was my Canon Speedlite 600EX triggering other flashes?
Can a tourist shoot a gun for recreational purpose in the USA?
Are there any sonatas with only two sections?
Why are solar panels kept tilted?
Are Allah and Hashem one and the same?
Were any of the books mentioned in this scene from the movie Hackers real?
Why is it harder to turn a motor/generator with shorted terminals?
What was the ring Varys took off?
Why did the soldiers of the North disobey Jon?
Meaning of "work with shame"
Wireless headphones interfere with Wi-Fi signal on laptop
Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
Do not cross the line!
Uh oh, the propeller fell off
How to cope with regret and shame about not fully utilizing opportunities during PhD?
There is an unexplained space between buttons
Differences between HashMap and Hashtable?What is the difference between public, protected, package-private and private in Java?What's the difference between SoftReference and WeakReference in Java?Difference between StringBuilder and StringBufferDifference between wait() and sleep()What is the difference between JDK and JRE?What is the difference between JSF, Servlet and JSP?Difference between HashMap, LinkedHashMap and TreeMapWhat's the difference between @Component, @Repository & @Service annotations in Spring?What is the difference between canonical name, simple name and class name in Java Class?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've a problem with an exercise. There is an unexplained space between the first and the second buttons on the scene. I've change the location of the buttons but still the first one has a space from the second one. What cause this and how can I make this space shorter?
https://imgur.com/hYolYE2
public void start(Stage myStage)
GridPane myPane = new GridPane();
myPane.setPadding(new Insets(10, 10, 10, 10));
myPane.setHgap(10);
myPane.setVgap(10);
Button btn1 = new Button("Computer Scinence");
Button btn2 = new Button("Chemistry");
Button btn3 = new Button("Arts");
DrawText txt1 = new DrawText("Computer Scince","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.GREEN);
DrawText txt2 = new DrawText("Chemistry","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.BLUE);
DrawText txt3 = new DrawText("Arts","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.YELLOW);
GridPane.setConstraints(btn1,0,1);
GridPane.setConstraints(btn2,1,1);
GridPane.setConstraints(btn3,2,1);
GridPane.setConstraints(txt1,0,2);
GridPane.setConstraints(txt2,0,3);
GridPane.setConstraints(txt3,0,4);
myPane.getChildren().addAll(btn1,btn2,btn3,txt1,txt2,txt3);
Scene myScene = new Scene(myPane,350,190);
myStage.setScene(myScene);
myStage.setTitle("Exercise 3_3");
myStage.show();
java javafx
add a comment |
I've a problem with an exercise. There is an unexplained space between the first and the second buttons on the scene. I've change the location of the buttons but still the first one has a space from the second one. What cause this and how can I make this space shorter?
https://imgur.com/hYolYE2
public void start(Stage myStage)
GridPane myPane = new GridPane();
myPane.setPadding(new Insets(10, 10, 10, 10));
myPane.setHgap(10);
myPane.setVgap(10);
Button btn1 = new Button("Computer Scinence");
Button btn2 = new Button("Chemistry");
Button btn3 = new Button("Arts");
DrawText txt1 = new DrawText("Computer Scince","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.GREEN);
DrawText txt2 = new DrawText("Chemistry","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.BLUE);
DrawText txt3 = new DrawText("Arts","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.YELLOW);
GridPane.setConstraints(btn1,0,1);
GridPane.setConstraints(btn2,1,1);
GridPane.setConstraints(btn3,2,1);
GridPane.setConstraints(txt1,0,2);
GridPane.setConstraints(txt2,0,3);
GridPane.setConstraints(txt3,0,4);
myPane.getChildren().addAll(btn1,btn2,btn3,txt1,txt2,txt3);
Scene myScene = new Scene(myPane,350,190);
myStage.setScene(myScene);
myStage.setTitle("Exercise 3_3");
myStage.show();
java javafx
2
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28
add a comment |
I've a problem with an exercise. There is an unexplained space between the first and the second buttons on the scene. I've change the location of the buttons but still the first one has a space from the second one. What cause this and how can I make this space shorter?
https://imgur.com/hYolYE2
public void start(Stage myStage)
GridPane myPane = new GridPane();
myPane.setPadding(new Insets(10, 10, 10, 10));
myPane.setHgap(10);
myPane.setVgap(10);
Button btn1 = new Button("Computer Scinence");
Button btn2 = new Button("Chemistry");
Button btn3 = new Button("Arts");
DrawText txt1 = new DrawText("Computer Scince","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.GREEN);
DrawText txt2 = new DrawText("Chemistry","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.BLUE);
DrawText txt3 = new DrawText("Arts","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.YELLOW);
GridPane.setConstraints(btn1,0,1);
GridPane.setConstraints(btn2,1,1);
GridPane.setConstraints(btn3,2,1);
GridPane.setConstraints(txt1,0,2);
GridPane.setConstraints(txt2,0,3);
GridPane.setConstraints(txt3,0,4);
myPane.getChildren().addAll(btn1,btn2,btn3,txt1,txt2,txt3);
Scene myScene = new Scene(myPane,350,190);
myStage.setScene(myScene);
myStage.setTitle("Exercise 3_3");
myStage.show();
java javafx
I've a problem with an exercise. There is an unexplained space between the first and the second buttons on the scene. I've change the location of the buttons but still the first one has a space from the second one. What cause this and how can I make this space shorter?
https://imgur.com/hYolYE2
public void start(Stage myStage)
GridPane myPane = new GridPane();
myPane.setPadding(new Insets(10, 10, 10, 10));
myPane.setHgap(10);
myPane.setVgap(10);
Button btn1 = new Button("Computer Scinence");
Button btn2 = new Button("Chemistry");
Button btn3 = new Button("Arts");
DrawText txt1 = new DrawText("Computer Scince","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.GREEN);
DrawText txt2 = new DrawText("Chemistry","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.BLUE);
DrawText txt3 = new DrawText("Arts","Times Roman",FontWeight.BOLD,FontPosture.ITALIC,20,Color.YELLOW);
GridPane.setConstraints(btn1,0,1);
GridPane.setConstraints(btn2,1,1);
GridPane.setConstraints(btn3,2,1);
GridPane.setConstraints(txt1,0,2);
GridPane.setConstraints(txt2,0,3);
GridPane.setConstraints(txt3,0,4);
myPane.getChildren().addAll(btn1,btn2,btn3,txt1,txt2,txt3);
Scene myScene = new Scene(myPane,350,190);
myStage.setScene(myScene);
myStage.setTitle("Exercise 3_3");
myStage.show();
java javafx
java javafx
asked Mar 23 at 14:17
vaStamvaStam
81
81
2
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28
add a comment |
2
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28
2
2
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28
add a comment |
1 Answer
1
active
oldest
votes
You can often debug GridPane
layout issues by turning on the grid lines:
myPane.setGridLinesVisible(true);
After recreating your application (you did not include your DrawText
class, so I'm just styling Labels instead) and turning on the grid lines reveals the issue:
You can see that the Computer Science Label
at GridPane
location 0, 1
has a greater width than the Computer Science Button
. This causes the GridPane
to expand the width of the first column to accommodate the Label
.
You have a couple of options to resolve this, depending on how you want the layout to work.
1) Set Column Span:
If you want to keep the Computer Science Button
the same size, but have the first column's width not expand to fit the Label
, just have that Label
span 2 columns:
GridPane.setColumnSpan(txt1, 2);
2) Increase Button Width:
If you'd like the Computer Science Button
to expand to fill the rest of the column, you can set its MaxWidth
property to use the maximum value:
btn1.setMaxWidth(Double.MAX_VALUE);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314639%2fthere-is-an-unexplained-space-between-buttons%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can often debug GridPane
layout issues by turning on the grid lines:
myPane.setGridLinesVisible(true);
After recreating your application (you did not include your DrawText
class, so I'm just styling Labels instead) and turning on the grid lines reveals the issue:
You can see that the Computer Science Label
at GridPane
location 0, 1
has a greater width than the Computer Science Button
. This causes the GridPane
to expand the width of the first column to accommodate the Label
.
You have a couple of options to resolve this, depending on how you want the layout to work.
1) Set Column Span:
If you want to keep the Computer Science Button
the same size, but have the first column's width not expand to fit the Label
, just have that Label
span 2 columns:
GridPane.setColumnSpan(txt1, 2);
2) Increase Button Width:
If you'd like the Computer Science Button
to expand to fill the rest of the column, you can set its MaxWidth
property to use the maximum value:
btn1.setMaxWidth(Double.MAX_VALUE);
add a comment |
You can often debug GridPane
layout issues by turning on the grid lines:
myPane.setGridLinesVisible(true);
After recreating your application (you did not include your DrawText
class, so I'm just styling Labels instead) and turning on the grid lines reveals the issue:
You can see that the Computer Science Label
at GridPane
location 0, 1
has a greater width than the Computer Science Button
. This causes the GridPane
to expand the width of the first column to accommodate the Label
.
You have a couple of options to resolve this, depending on how you want the layout to work.
1) Set Column Span:
If you want to keep the Computer Science Button
the same size, but have the first column's width not expand to fit the Label
, just have that Label
span 2 columns:
GridPane.setColumnSpan(txt1, 2);
2) Increase Button Width:
If you'd like the Computer Science Button
to expand to fill the rest of the column, you can set its MaxWidth
property to use the maximum value:
btn1.setMaxWidth(Double.MAX_VALUE);
add a comment |
You can often debug GridPane
layout issues by turning on the grid lines:
myPane.setGridLinesVisible(true);
After recreating your application (you did not include your DrawText
class, so I'm just styling Labels instead) and turning on the grid lines reveals the issue:
You can see that the Computer Science Label
at GridPane
location 0, 1
has a greater width than the Computer Science Button
. This causes the GridPane
to expand the width of the first column to accommodate the Label
.
You have a couple of options to resolve this, depending on how you want the layout to work.
1) Set Column Span:
If you want to keep the Computer Science Button
the same size, but have the first column's width not expand to fit the Label
, just have that Label
span 2 columns:
GridPane.setColumnSpan(txt1, 2);
2) Increase Button Width:
If you'd like the Computer Science Button
to expand to fill the rest of the column, you can set its MaxWidth
property to use the maximum value:
btn1.setMaxWidth(Double.MAX_VALUE);
You can often debug GridPane
layout issues by turning on the grid lines:
myPane.setGridLinesVisible(true);
After recreating your application (you did not include your DrawText
class, so I'm just styling Labels instead) and turning on the grid lines reveals the issue:
You can see that the Computer Science Label
at GridPane
location 0, 1
has a greater width than the Computer Science Button
. This causes the GridPane
to expand the width of the first column to accommodate the Label
.
You have a couple of options to resolve this, depending on how you want the layout to work.
1) Set Column Span:
If you want to keep the Computer Science Button
the same size, but have the first column's width not expand to fit the Label
, just have that Label
span 2 columns:
GridPane.setColumnSpan(txt1, 2);
2) Increase Button Width:
If you'd like the Computer Science Button
to expand to fill the rest of the column, you can set its MaxWidth
property to use the maximum value:
btn1.setMaxWidth(Double.MAX_VALUE);
edited Mar 23 at 15:29
answered Mar 23 at 15:23
ZephyrZephyr
4,98721033
4,98721033
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55314639%2fthere-is-an-unexplained-space-between-buttons%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
have a look at the java doc of GridPane, in particular the specification of how it sizes its content
– kleopatra
Mar 23 at 14:28