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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:37:06+00:00 2026-06-16T22:37:06+00:00

The following problem boggled my mind, so I came here for some help. After

  • 0

The following problem boggled my mind, so I came here for some help.

After experimenting I ended up with this block of code:

JTextArea chatPanel = null;
JScrollPane scrollPanel = null;

if(chatPanel == null)
{
    chatPanel = new JTextArea("derp");
    chatPanel.setEditable(false);
    chatPanel.setForeground(new Color(10,191,26));
    chatPanel.setOpaque(false);
    scrollPanel = new JScrollPane(chatPanel);
    scrollPanel.setOpaque(false);
    scrollPanel.getViewport().setOpaque(false);
    scrollPanel.setBorder(BorderFactory.createEmptyBorder());
}

//## marked area ##         
scrollPanel.setBounds(9,596,435,138);
pane.add(scrollPanel);              

The result? Nothing shows up. The text area with “derp” in it I expected is not there, just an empty scroll panel. Now, if I go to the ## marked area ## and replace it with this:

chatPanel.append("Hello.");

the chatPanel shows up fine in the scrollPanel, with its text being “derpHello.”. Any ideas as per what’s going on?

For the record, pane is a simple container with a null layout that otherwise displays eveyrthing fine. Declaration, just for the record:

Container pane = getContentPane()
pane.setLayout(null);
  • 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-16T22:37:07+00:00Added an answer on June 16, 2026 at 10:37 pm

    I have no problem with the following code, I can see the “derp” in green just fine:

    import java.awt.Color;
    import java.awt.Container;
    
    import javax.swing.BorderFactory;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    
    public class TestTextArea {
    
        private void initUI() {
            JFrame frame = new JFrame("test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JTextArea chatPanel = null;
            JScrollPane scrollPanel = null;
            Container pane = frame.getContentPane();
            pane.setLayout(null);
            if (chatPanel == null) {
                chatPanel = new JTextArea("derp");
                chatPanel.setEditable(false);
                chatPanel.setForeground(new Color(10, 191, 26));
                chatPanel.setOpaque(false);
                scrollPanel = new JScrollPane(chatPanel);
                scrollPanel.setOpaque(false);
                scrollPanel.getViewport().setOpaque(false);
                scrollPanel.setBorder(BorderFactory.createEmptyBorder());
            }
    
            // ## marked area ##
            scrollPanel.setBounds(9, 596, 435, 138);
            pane.add(scrollPanel);
            frame.validate();
            frame.setSize(600, 800);
            frame.setVisible(true);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new TestTextArea().initUI();
                }
            });
        }
    
    }
    

    Now, I would really advise you to use an appropriate LayoutManager instead of that null layout. That would allow you to use pack() and revalidate() and have a much simpler and more maintainable code.

    There must be something else that your code does not illustrate for now. Try to put an SSCCE.

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

Sidebar

Related Questions

Following problem: Website build with PHP/HTML working We want to change this site to
The following problem I can't really wrap my mind around, so really if you
The following problem has been puzzling me for a couple of days (nb: this
I have the following problem. I have C code that acquires a PNG image
I have the following problem, maybe someone can help me (or explain, where my
I've got the following problem: after the user clicks on a thumbnail image, a
following problem. I need a div layer over my webpage . This layer should
I have the following problem. I am trying to integrate a large code written
Following Problem: I need something like an empty scope. Which means that this scope
Hello I have the following problem: I have some pages (php includes) which I

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.