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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:53:14+00:00 2026-05-13T16:53:14+00:00

I have a JPanel that I want to use to contain 3 vertical components:

  • 0

I have a JPanel that I want to use to contain 3 vertical components:

  1. a JLabel
  2. a JTextField
  3. a JScrollPane

I want all 3 components to fill the JPanel‘s width. I want the JLabel and JTextField to use their normal heights and the JScrollPane to use the rest.

BoxLayout almost works, except it seems like the JTextField and JScrollPane share the “extra” space when the JPanel is made large.

What can I do?

  • 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-13T16:53:15+00:00Added an answer on May 13, 2026 at 4:53 pm

    Create a BorderLayout. Put the JScrollPane in its center.

    Create a JPanel with a BoxLayout. Put the JLabel and JTextField in that, vertically. Put that JPanel into the NORTH side of the BorderLayout.

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

Sidebar

Related Questions

Give that I have written a JPanel with many different components on it, is
I am creating a program that uses JFrame, JPanel, JLabel and all other sorts
I want to overlap two image. For that, I use JLabel and set an
I have a class extending JPanel that I want to embed into a JFrame
I have a JPanel that holds a JScrollPane that holds a JPanel as such:
I have a JFrame that contains a display JPanel with JTextField and a control
I have sever JPanels which have to be ordered vertically. For that I want
I have a JPanel that has a button in it. The location of the
I have a JPanel that encapsulates two JPanels, one on top of the other.
I have a JPanel that implements custom drawing to draw a background. Over this,

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.