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

  • Home
  • SEARCH
  • 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 8079707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:11:41+00:00 2026-06-05T16:11:41+00:00

I have a label which would display strings from 0 ft to say 999

  • 0

I have a label which would display strings from “0 ft” to say “999 ft”, so maximum it would take string of size 6. I’m using a grid layout so that i could place that label in a particular column where it should be. I want a background for the label too. But the problem is i cant properly set the size of background.

I want to size down the black part to only the required amount which im not ablet to do

    public Controller() {
    super(new GridLayout(9, 9));
    try {
        Background = ImageIO.read(getClass().getResourceAsStream(
                "background.jpg"));
        TestImage = ImageIO.read(getClass().getResourceAsStream(
                "VTOLHorizontalLevelIndicator.png"));
        setPreferredSize(new Dimension(Background.getWidth(null),
                Background.getHeight(null)));

    } catch (IOException ex) {
        ex.printStackTrace();
    }

    for (Direction direction : Direction.values()) {
        directionMap.put(direction, false);
    }
    setKeyBindings();
    Timer timer = new Timer(TIMER_DELAY, new TimerListener());
    timer.start();
    int i = 3;
    int j = 11;
    JLabel[][] panelHolder = new JLabel[i][j];
    setLayout(new GridLayout(i, j));

    for (int m = 0; m <= 2; m++) {
        for (int n = 0; n <= 10; n++) {
            if (m == 1 && n == 1) {
                lblAltitude.setFont(new Font("Gotham Bold",1,12));
                lblAltitude.setToolTipText("Altitude");
                lblAltitude.setOpaque(true);
                lblAltitude.setBackground(Color.black);
                lblAltitude.setMinimumSize(new Dimension(50,25));
                add(lblAltitude);
            } else {
                panelHolder[m][n] = new JLabel(" ");
                add(panelHolder[m][n]);
            }
        }
    }

}

the above code shows the constructor from which I’m initializing the the GridLayout and the label.
Am I using the proper layout? My main concern is getting labels in right places , may not be in a grid fashion but at certain coordinates in this GUI.

  • 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-05T16:11:42+00:00Added an answer on June 5, 2026 at 4:11 pm

    GridLayout will expand all of the components to fill the panel (giving each component equal size).

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

Sidebar

Related Questions

I have a button, the label of which I want to change back and
I use ASP.NET and have a label control on my page, which I fill
Ok, I have a label, inside this label is a div, which contains an
I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
I have created an iframe which contains the label, powered by MyWebsite.site The iframe
Basically I have a series of divs which contains a label and an input
At the moment I have the following code which works fine. label = new
hello everybody i have a listbox within which is a datatemplate.Inside it is checkbox,textbox,label...Wat
I have an updateprogress in my aspx file, which has a label control in
I have a nested form in which I would like the form fields to

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.