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;








0















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();











share|improve this question

















  • 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


















0















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();











share|improve this question

















  • 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














0












0








0








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();











share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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













  • 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













1 Answer
1






active

oldest

votes


















6














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:



screenshot 1



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);


screenshot 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);


screenshot 3






share|improve this answer

























    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
    );



    );













    draft saved

    draft discarded


















    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









    6














    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:



    screenshot 1



    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);


    screenshot 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);


    screenshot 3






    share|improve this answer





























      6














      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:



      screenshot 1



      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);


      screenshot 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);


      screenshot 3






      share|improve this answer



























        6












        6








        6







        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:



        screenshot 1



        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);


        screenshot 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);


        screenshot 3






        share|improve this answer















        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:



        screenshot 1



        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);


        screenshot 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);


        screenshot 3







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 23 at 15:29

























        answered Mar 23 at 15:23









        ZephyrZephyr

        4,98721033




        4,98721033





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?