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 7587889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:47:16+00:00 2026-05-30T19:47:16+00:00

Pretty straightforward issue. My Java AWT (not Swing) label is simply not showing up.

  • 0

Pretty straightforward issue. My Java AWT (not Swing) label is simply not showing up. Most of the following code isn’t even being used (for debugging this issue).

Just a note: this is within a Frame’s constructor (and yes I have added several other panels and such that work just fine). Secondly, the frame’s layout has been set to null.

I’m stumped.

File inf = new File("instructions.txt");
        Label ilb;
        if(inf.exists())
        {
            Log.v("Loading instructions");

            try
            {
                FileInputStream fis = new FileInputStream(inf);
                byte[] insb = new byte[65535];
                fis.read(insb);
                fis.close();
                String inst = new String(insb);
                ilb = new Label("test", Label.LEFT);
                File fntfile = new File("font/pf_tempesta_seven.ttf");
                Font infnt = null;
                try {
                    FileInputStream ffis = new FileInputStream(fntfile);
                    infnt = Font.createFont(Font.TRUETYPE_FONT, ffis);
                    ffis.close();
                } catch (FontFormatException e) {
                    Log.e("Could not format LCD font!", e);
                } catch (IOException e) {
                    Log.e("Could not read LCD font file!", e);
                }

                if(infnt == null)
                    infnt = new Font("Trebuchet MS", Font.PLAIN, 8);
                else
                    infnt = infnt.deriveFont(8.0f);

                //ilb.setFont(infnt);
                //ilb.setForeground(new Color(123, 123, 123));

                //ilb.setPreferredSize(new Dimension(350, 400));
                //ilb.setSize(350, 400);

                //ilb.setLocation(580, 190);

                Log.d("adding label");
                add(ilb);

            } catch(IOException e) {
                Log.e("Could not read instructions!", e);
            }
        }else
            Log.w("Instructions file not found!");
  • 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-05-30T19:47:17+00:00Added an answer on May 30, 2026 at 7:47 pm

    As @JBNizet suggested, null layouts don’t work with all AWT components.

    I was thrown off since my Panels were positioned just fine with a null layout on my Frame, whereas Labels require a basic layout in order to display. I was tempted to go as far as saying all other components had the same ‘feature’, but another part of my code proved that point wrong:

    // Load Image
            Log.v("Loading header image");
            _iBG = new ImageIcon("img/hpcount_top_bg.png").getImage();
    
            // Set size
            setSize(1024, 152);
            setPreferredSize(new Dimension(1024, 152));
    
            // Set position
            setLocation(0, 0);
    
            // Set visible
            setVisible(true);
    
            // Set layout
            setLayout(null);
    
            // Add children
            add(new Exit()); // Exit extends java.awt.Button
    

    The above code (which is located within the constructor of a class extending java.awt.Panel) works perfectly.

    My workaround is to put the label inside another Panel with a layout (messy, but it works) and position that panel within the Frame absolutely to achieve the same effect.

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

Sidebar

Related Questions

Pretty straightforward question: Why the output of the following SQL is not null? SELECT
Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand
Pretty straightforward, but I just want to know which is faster. I think simply
For the following pretty straightforward task: query a list of products from a DB
This should be a pretty straightforward issue -- I'm trying to compile Lua (or
The code is pretty much straightforward: <TextBlock TextAlignment=Center Text={Binding TimeAgo} Foreground=White FontSize=12 FontFamily=Calibri Background=Transparent/>
Pretty straightforward: I'm looking to do the same as this but in winforms. Everything
I'm writing a pretty straightforward e-commerce app in asp.net , do I need to
My question is pretty straightforward: You are an executable file that outputs Access granted
This should be pretty straightforward I would think. I have this string: [quote=Joe Johnson|1]Hi![/quote]

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.