Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:48:43+00:00 2026-06-16T16:48:43+00:00

I have the following code to load the fxml file. I want to change

  • 0

I have the following code to load the fxml file. I want to change the width of the button. I am able to access the two labels using fxmlLoader.getNamespace().get("id"), but for some reason I don’t see the button inside ObservableMap returned by getNamespace(). Why is it so/

FXML file

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<GridPane fx:controller="org.netbeans.modules.mavenproject1.controller.KeyController" xmlns:fx="http://javafx.com/fxml" >
    <padding>
        <Insets top="5" right="5" bottom="5" left="5"/>
    </padding>
    <children>
        <Button maxHeight="45.0" maxWidth="45.0" minHeight="45.0" minWidth="45.0" mnemonicParsing="false" prefHeight="45.0" prefWidth="45.0" style="" styleClass="alphabet-button" text="~" textAlignment="CENTER" textOverrun="ELLIPSIS">
            <graphic>
                <GridPane alignment="TOP_LEFT">
                    <padding>
                        <Insets top="1" right="1" bottom="1" left="1"/>
                    </padding>
                    <children>
                        <Label text="" fx:id="mainTextLabel" GridPane.columnIndex="0" GridPane.rowIndex="0" />
                        <Label text="" fx:id="shiftTextLabel" GridPane.columnIndex="0" GridPane.rowIndex="1" />
                    </children>
                    <columnConstraints>
                        <ColumnConstraints hgrow="SOMETIMES" minWidth="20.0" prefWidth="20.0" />
                        <ColumnConstraints hgrow="SOMETIMES" minWidth="20.0" prefWidth="20.0" />
                    </columnConstraints>
                    <rowConstraints>
                        <RowConstraints minHeight="20.0" prefHeight="20.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="20.0" prefHeight="20.0" vgrow="SOMETIMES" />
                    </rowConstraints>
                </GridPane>
            </graphic>
            <stylesheets>
                <URL value="@../styles/keyboard.css" />
            </stylesheets>
        </Button>
    </children>
</GridPane>

Controller Constructor

 public Key(){
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/key.fxml"));
    fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>(){
        @Override
        public Object call(Class<?> param){
            return keyController = new KeyController();
        }
    });

    try {            
        keyView = (Node) fxmlLoader.load();            
    } catch (IOException exception) {
            throw new RuntimeException(exception);
    }
    mainTextLabel = (Label) fxmlLoader.getNamespace().get("mainTextLabel");
    shiftTextLabel = (Label) fxmlLoader.getNamespace().get("shiftTextLabel");

    getChildren().add(keyView);
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:48:44+00:00Added an answer on June 16, 2026 at 4:48 pm

    I created this as a wiki post. I found the solution by trial and error ( seems like the best way to learn programming ), but if somebody can show me a location on oracle docs where the following detail is listed, you have my upvote.

    Answer

    Just add fx:id to the button.

    Before

    <Button maxHeight="45.0" maxWidth="45.0" minHeight="45.0" minWidth="45.0" mnemonicParsing="false" prefHeight="45.0" prefWidth="45.0" style="" styleClass="alphabet-button" text="~" textAlignment="CENTER" textOverrun="ELLIPSIS">

    After

    <Button fx:id="button" maxHeight="45.0" maxWidth="45.0" minHeight="45.0" minWidth="45.0" mnemonicParsing="false" prefHeight="45.0" prefWidth="45.0" style="" styleClass="alphabet-button" text="~" textAlignment="CENTER" textOverrun="ELLIPSIS">

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which I want to load values on a selection
I have the following code to load a file after creating a web page
I have following code structure, where i am trying to change the css file
I have the following code in my file to load a div with HTML
i have the following code to try and load a local html page in
I have the following code - it is used to load a drop down
I have the following code: $(function () { $(#ARO).load('/DA.aspx?section=ARO #ARO', function() { DoSomething1(); });
I have the following code in my application to load some data from my
I have the following code, in which Boost.Local uses a function callback to load
I have used the following code in a number of applications to load .DLL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.