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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:15:39+00:00 2026-06-13T21:15:39+00:00

So basically I want to create this sort of a GUI, but because of

  • 0

GUI

So basically I want to create this sort of a GUI, but because of my inexperience with Java GUIs, I cannot figure out which Layout Manager to use. I’ve tried Flow, Border, Grid, but none of them allow me to create this sort of a GUI without messing up the alignments somewhere.

Any suggestions? How should I decide on a layout manager in the future, or is it something which will come with experience?

I’d prefer to use a simple to use layout, as this is a very basic GUI and I don’t think something like MiGLayout should be necessary.

  • 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-13T21:15:40+00:00Added an answer on June 13, 2026 at 9:15 pm

    I’d use a combination of compound panels and layouts. Apart from making easier to get the layout to work, you could also isolate areas of responsibility within their own class.

    enter image description here

    public class TestLayout13 {
    
        public static void main(String[] args) {
            new TestLayout13();
        }
    
        public TestLayout13() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException ex) {
                    } catch (InstantiationException ex) {
                    } catch (IllegalAccessException ex) {
                    } catch (UnsupportedLookAndFeelException ex) {
                    }
    
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new FormPane());
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
    
            });
        }
    
        public class FormPane extends JPanel {
    
            public FormPane() {
                setBorder(new EmptyBorder(8, 8, 8, 8));
                setLayout(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.weightx = 1;
    
                NamePane namePane = new NamePane();
                namePane.setBorder(new CompoundBorder(new TitledBorder("Name"), new EmptyBorder(4, 4, 4, 4)));
                add(namePane, gbc);
    
                gbc.gridy++;
    
                EMailPane emailPane = new EMailPane();
                emailPane.setBorder(new CompoundBorder(new TitledBorder("E-Mail"), new EmptyBorder(4, 4, 4, 4)));
                add(emailPane, gbc);
            }
    
        }
    
        public class NamePane extends JPanel {
    
            public NamePane() {
                setLayout(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.anchor = GridBagConstraints.EAST;
    
                add(new JLabel("First Name:"), gbc);
                gbc.gridx += 2;
                add(new JLabel("Last Name:"), gbc);
                gbc.gridy++;
                gbc.gridx = 0;
                add(new JLabel("Title:"), gbc);
                gbc.gridx += 2;
                add(new JLabel("Nickname:"), gbc);
    
                gbc.gridx = 1;
                gbc.gridy = 0;
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.anchor = GridBagConstraints.WEST;
                gbc.weightx = 0.5;
                add(new JTextField(10), gbc);
                gbc.gridx += 2;
                add(new JTextField(10), gbc);
                gbc.gridy++;
                gbc.gridx = 1;
                add(new JTextField(10), gbc);
                gbc.gridx += 2;
                add(new JTextField(10), gbc);
    
                gbc.gridx = 0;
                gbc.gridy++;
                gbc.anchor = GridBagConstraints.EAST;
                gbc.weightx = 0;
                gbc.fill = GridBagConstraints.NONE;
                add(new JLabel("Format:"), gbc);
    
                gbc.anchor = GridBagConstraints.WEST;
                gbc.gridx++;
                gbc.weightx = 1;
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.gridwidth = GridBagConstraints.REMAINDER;
                add(new JComboBox(), gbc);            
            }        
        }
    
        protected class EMailPane    extends JPanel {
    
            public EMailPane() {
                JPanel detailsPane = new JPanel(new GridBagLayout());
                GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.anchor = GridBagConstraints.EAST;
                detailsPane.add(new JLabel("E-Mail Address:"), gbc);
    
                gbc.gridx++;
                gbc.anchor = GridBagConstraints.WEST;
                gbc.weightx = 1;
                gbc.fill = GridBagConstraints.HORIZONTAL;
                detailsPane.add(new JTextField(10), gbc);
    
                gbc.gridy++;
                gbc.gridx = 0;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.weighty = 1;
                gbc.gridwidth = GridBagConstraints.REMAINDER;
                detailsPane.add(new JScrollPane(new JList()), gbc);
    
                JPanel buttonsPane = new JPanel(new GridBagLayout());
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.weightx = 1;
                gbc.fill = GridBagConstraints.HORIZONTAL;
    
                buttonsPane.add(new JButton("Add"), gbc);
                gbc.gridy++;
                buttonsPane.add(new JButton("Edit"), gbc);
                gbc.gridy++;
                buttonsPane.add(new JButton("Delete"), gbc);
    
                gbc.gridy++;
                gbc.weighty = 1;
                gbc.anchor = GridBagConstraints.NORTH;
                buttonsPane.add(new JButton("As Default"), gbc);
    
                JPanel formatPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
                formatPane.setBorder(new TitledBorder(new EmptyBorder(1, 1, 1, 1), "Mail Format:"));
                formatPane.add(new JRadioButton("HTML"));
                formatPane.add(new JRadioButton("Plain"));
                formatPane.add(new JRadioButton("Custom"));
    
                setLayout(new BorderLayout());
                add(detailsPane);
                add(buttonsPane, BorderLayout.LINE_END);
                add(formatPane, BorderLayout.PAGE_END);                
            }            
        }        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I want this sort of functionality but less complicated: http://www.blueacorn.com/team/ I have a
So basically I want to create a GUI app using PySide and the Qt
Basically, I want to create a table like this: I created a grid, and
Basically I want to create one large object of many object in JavaScript. Something
I have php generating html and I want to create layers. Basically I want
I want to create own filetype to save objects in my app. Basically, I
I want to create a Google Docs document from within Haskell, so basically I
How to create imaged scrollbars, for example: http://www.openstudio.fr/jquery/index.htm Basically, I want to create my
I basically want to do: git checkout branchA git checkout -b branchB <commit_id> which
Basically, I want an exact copy of the XML, except I'd like to sort

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.