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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:24:43+00:00 2026-05-25T11:24:43+00:00

I have made a JFrame and inside that frame, there is panel on which

  • 0

I have made a JFrame and inside that frame, there is panel on which I have placed various containers using GridBagLayout. I have set layout of JFrame to be BorderLayout, and added panel in BorderLayout.WEST. I want to show that panel’s containers at the top left corner. How can I do that?

Even if I try to add panel to BorderLayout.NORTH then also it is displayed in top center but instead I want to be in top left corner.

Is there any way to do that? I.E. any other layout I should use as I want to show

label1
button1     button2     button3

label2
button1     button2     button3

label 3
button1     button2     button3
  • 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-25T11:24:44+00:00Added an answer on May 25, 2026 at 11:24 am

    This is easy to do with just GridLayout and BorderLayout.

    Label-Button Layout

    import java.awt.*;
    import javax.swing.*;
    
    class LabelButtonLayout {
    
        public static Component getButtonLayout(int num) {
            JPanel p = new JPanel(new BorderLayout(3,3));
    
            p.add(new JLabel("Label " + num), BorderLayout.NORTH);
    
            JPanel b = new JPanel(new GridLayout(1,0,25,5));
            for (int ii=1; ii<4; ii++) {
                b.add(new JButton("Button " + ii));
            }
            p.add(b, BorderLayout.CENTER);
    
            return p;
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater( new Runnable() {
                public void run() {
                    JPanel gui = new JPanel(new GridLayout(0,1,3,15));
                    for (int ii=1; ii<4; ii++) {
                        gui.add(getButtonLayout(ii));
                    }
                    JOptionPane.showMessageDialog(null, gui);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a new windows service which works fine using barebone code (just
i have made user-register.tpl.php file. And i have set many text field in that.
I have a JWindow and a JFrame both I have made runnable and both
I have made some code which exports some details of a journal article to
I have made a class which a form can inherit from and it handles
I have made an application (for my self) for feeds reading, using SyndicationFeed ,
I have made one project which is showing the inventory of the stock of
i have made a program in C using the gcc compiler. Right now it
I have made a simple Rails application that allows people to comment on posts.
I have made this piece of code that makes a roll hover effect on

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.