Misfortunes of alignment

Sorry for the Newbie question, but I'm having some strange results trying to align the contents of a GridPane.

First, here's my hierarchy:
In a TabPane, I have a tab that contains a BorderPane. The BorderPane has a label in the upper part, a label in the left and a GridPane in the Center. Line 1 contains 10 labels marked '1' to '10', starting in column 2. Column 1 contains 10 labels also labeled "1" through "10" from rank 2. I then a grid of 10 x 10 of option buttons start grid 2.2 through 11.11.

When I resize the application, the labels in the BorderPane move at their Center as you like, but won't resize nodes in the GridPane. I tried to use constraints of line and column, placing at 10%, but I get strange results. Redimensionneront columns, the last column goes out of the window but the lines have not changed. I also see the label in the left area of the BorderPane is no longer visible.

Any suggestions on how I can get the GridPane to resize correctly?

Thank you!

Isn't the problem simply that you have 11 rows/columns, each with 10% of the height and width?

It works for me:

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.RowConstraints;
import javafx.stage.Stage;

public class RadioButtonGrid extends Application {

  @Override
  public void start(Stage primaryStage) {
    final BorderPane root = new BorderPane();
    final Label colHeader = new Label("Main Column Header");
    colHeader.setMaxWidth(Double.POSITIVE_INFINITY);
    colHeader.setAlignment(Pos.CENTER);
    root.setTop(colHeader);
    final Label rowHeader = new Label("Main Row Header");
    root.setLeft(rowHeader);
    rowHeader.setRotate(90);
    rowHeader.setMaxHeight(Double.POSITIVE_INFINITY);
    rowHeader.setAlignment(Pos.CENTER);
    final int numRows = 10;
    final int numCols = 10;
    final GridPane grid = new GridPane();
    ColumnConstraints leftColConstraints = new ColumnConstraints();
    leftColConstraints.setPercentWidth(10);
    RowConstraints topRowConstraints = new RowConstraints();
    topRowConstraints.setPercentHeight(10);
    grid.getColumnConstraints().add(leftColConstraints);
    grid.getRowConstraints().add(topRowConstraints);
    for (int x = 0; x < numCols; x++) {
      grid.add(new Label("ABCDEFGHIJ".substring(x, x + 1)), x + 1, 0);
      ColumnConstraints colConstraints = new ColumnConstraints();
      colConstraints.setPercentWidth(9);
      grid.getColumnConstraints().add(colConstraints);
      for (int y = 0; y < numRows; y++) {
        grid.add(new RadioButton(), x + 1, y + 1);
      }
    }
    for (int y = 0; y < numRows; y++) {
      grid.add(new Label(Integer.toString(y + 1)), 0, y + 1);
      RowConstraints rowConstraints = new RowConstraints();
      rowConstraints.setPercentHeight(9);
      grid.getRowConstraints().add(rowConstraints);
    }
    root.setCenter(grid);
    primaryStage.setScene(new Scene(root, 600, 600));
    primaryStage.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

Tags: Java

Similar Questions

  • Move the 3 letters for word-how to align results in Keynote?

    As you can see, I am to spoil it enormously. What step I got?

    Thank you.

    In your example, I can't tell what you are trying to do.

    I'll assume that the word "cat" is your difficulty. If you have each of the letters in an individual text box and then select all and choose align > way. If the letters are not text boxes you have set "basic" for the letter t and maybe "character spacing" to the other letters. Enter these words in the help.

  • How to change the default alignment of text in the cells in a table on the demand for numbers?

    I'm new to Mac. I own a MacBook pro MF839HN/A and currently using the 3.6.2 release NUMBERS (2577). I want to know if I can change the default alignment of text in the cell in a table of NUMBERS application? Also, when I select all the cells in a table to change their alignment, I can only change the horizontal alignment of the text and not the vertical alignment. To change the vertical alignment of the text in a cell, I have to select them individually. Help me with two questions.

    The only way I know is to create a table that is set up as you like, then save the empty document as a template customized by using the menu item "file > save as template:

  • moving text, very slightly to align with precision

    Hello

    I do a menu in pages and I would like to move some of the prices on the right side, so they all line up nicely. I don't want to choose all the 'align right' as then the food not all vertically aligned. Is there a command or action that allows me to just move the desired text by small steps?

    Thank you

    There is no adjustment convenient to move the text in small increments. Maybe with InDesign, Quark, or Scribus, but not in Pages.

    If you want your menu items and prices aligned differently and especially perfectly aligned to the right, then use a table that has cell formatting for this purpose.

  • Paging in the poorly aligned table of contents

    As you can see in the screenshot below, the pagination is right-aligned, sometimes in the table of contents, and sometimes it seems all wrong. What should I do to fix this?

    Hello joachim,.

    Pages 5.6.2 on OS X El Capitan 10.11.5

    Menu > view > show rules.

    You can select (click) each level (Style) of the Table of contents and view the parameters of the rule.

    With the second level selected, look in Control Panel of Format > text > tabs

    Please call with questions.

    Kind regards

    Ian.

  • Facebook ask for enable cookies when I already did. Page is white and blue just link on the left-aligned words.

    Facebook appears on white background and text, some with links left alignment.

    allowed, history, cookies, cache, everything I searched on google.

    cookies are already enabled.

    all other websites are ok except fb.

    pls help.

    Apparently, facebook could have updated their ads stuff that make my anti-ad on my phone does not not with facebook. fuck Facebook.

  • How can I display a grid of horizontal alignment in Pages.

    How can I display a grid of horizontal alignment in pages. I can show a vertical, but there seems to be no option to show a horizontal. I use El Capitan with maps, version 5.6.2 Pages.

    Pages v5.6.2 has horizontal and vertical guides, but no grid. The vertical guide is enabled in the menu Pages: preferences: sovereign.

    With the two visible leaders after menu display: display the rule, place the cursor of the black needle on the edge of the respective sovereign and then click. When you see the following icon, drag the new guide in your document. Several vertical and horizontal guides may be present. The view menu has an element of Guides to hide menu or erased.

    • Indicator of horizontal ruler guide
    • Indicator of vertical ruler guide
  • Advice needed on the alignment of the text in an e-mail.

    I'm developing an email with a small logo (with a web link) with a descriptive text to the right. I tried to put a picture here, but it won't download for some reason any so posted it here: http://imgur.com/gallery/lHRD8VC/new

    I can align the text on the image, but when it falls in the second line, it drops below the logo image and left justified. I want it all back right of the logo to look neat. I know that I can use the tap and space to get what I want in the email, but she is shown in a smaller window when it is created, all goes pear-shaped.

    Any help would be appreciated.

    use a table. 1 row end on 2 columns. Picture in the text first, in the second.

  • alignment of the footer

    Im trying to align (justify) of text in the footer of the pages, but the buttons is not active.

    What can I do?

    Hi horisize,

    Insert the text into a text box in the body of the document. Better if the text box has no borders. Check the box and the alignment buttons will be active. Justify. Cut and paste the box in the page footer.

    Kind regards

    Ian.

  • Why, suddenly, my desktop icons are difficult to align because they can be moved very small distances?

    For years, my desktop icons have acted as if they have so many 'slots' to enter in on the office. But this has never been a problem. They were easier to align because they were right next to each other, or a 'slot' above/below/apart.

    Now, for some reason, I can travel distances of small icons on the desktop, as if they were scalar elements which can be minimally pushed open. Suddenly there are not more "slots", and sort of paradoxically icons are more difficult to assemble and align because I have to keep their repositioning so that they are straight. Before, they were either straight, or a whole notch offline.

    It is NOT correct. Right-click and select Show , and then turn on Align

  • Questions about css vertical-align

    given a list of the CSA page: Technologies of Mac OS X

    I do not understand vertical-align.  I will like to center the text in the vertical alignment.  I don't know what basis means, or intermediate. Where Ref base?  background of the characters or what?  I don't know how to work the percentages.

    In addition to all this lack of knowledge, 5% of the centers of communities Word for some reason I don't know.  'Contact support' appears to be centered for some reason any.

    with this css

          /* top line:
             Communities                Contact support */
          header#j-header nav#j-globalNav-bg {
              background-color: tan !important;
              margin-top: -15px !important;
             }
           /* Communities */
          div#body-apple header div#apple-site-title a {
            
              font-size: 20px !important;
              background-color: yellow !important;
              vertical-align: 5% !important;
             }
          /* Contact Support */
          div#body-apple header ul#contact-support-link a {background-color: pink !important;}
    
  • Whenever I go to hotmail my s and outs are not aligned if I open another tab and go bask in hotmail is fine if I open an e-mail and then back in the box of

    When I go on my hotmail all titles half e-mail superior is readable when I open another tab that come back, it's very readable, if I open an e-mail once again only half is showing again fine go to another tab/site back and all it is all aligned. This is not the case with Safari

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe

    You can have zoomed pages by accident.
    Reset the zoom of page on pages that are causing problems.

    • View > Zoom > reset (Ctrl / command + 0 (zero))
  • Why do Garageband and align myself a copy and paste the track with the original track

    That's what it's going to go

    When you copy and paste a region must be inserted exactly where the crosshair is positioned. Have you tried?

    Or, to align a region when copying from another track, hold option key while dragging the region towards the destination track. He should be perfectly aligned.

    I saw the same problem sometimes that a region refuses to be shifted. Then save the project, and restarting of GarageBand should help.

  • iMovie 10.1.2 Photo alignment

    I'm trying to align my photos on the left side of the preview screen. In this way, I'll be able to easily add text to the right. How to achieve this?

    Thank you very much for the help!

    Align your photos to left is to use the split function on a black background (or whatever color), with text superimposed on the background.  Scrolling title can be adapted to write the text and then you can take a screenshot of it for a static effect, import the screen shot in your project and then superimpose your photo, above, then split screen by selecting the text overlay function (the button that looks like to the overlap of the places in the toolbar at the top of your screen).

  • Motion - Final Cut title - related text alignment

    I created a title Final Cut in Motion 5.

    Then I copied the text to a different layer and created an animation.

    The text of the first, is published, so I can customize later for Final Cut Pro X.

    So the second text corresponds to the text of the edited user, I've added a link to the text using the source: Object.Text, Object.Text destination.

    When I use it in Final Cut, the text is changed and I can even looking fonts, size etc.

    The problem is, that the second text alignment is left, I even specified that it is centered.

    How can solve this problem?

    I can link somehow the alignment of another text?

    Here's what it looks like in Motion 5:

    Here is the title in Final Cut Pro X, where the animated text left aligned instead of centered:

    Want to make a copy of the Clone of the text layer, not bind.

Maybe you are looking for