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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:12:08+00:00 2026-05-21T16:12:08+00:00

Here is a screenshot of my JFrame . This will be the main window

  • 0

Here is a screenshot of my JFrame. This will be the main window to my application.

enter image description here

So the problem is that all the buttons are inline with each other, whereas I want them to be one under the other i.e. Add Contact under Show Contacts.

So how can I do that?

Here is my code for the JFrame.

public class CRUDFrame extends JFrame {
    public CRUDFrame(){
        super("AppCRUD");
        setLayout(new FlowLayout());
        JButton button1, button2, button3, button4;

        button1 = new JButton(" Show Contacts ");
        button2 = new JButton(" Add Contact ");
        button3 = new JButton(" Update Number in a Contact ");
        button4 = new JButton(" Delete a Contact ");
        add(button1);       
        add(button2);  
        add(button3); 
        add(button4);
    }
}
`
  • 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-21T16:12:09+00:00Added an answer on May 21, 2026 at 4:12 pm

    There have been some good answers centered around ‘use a layout’. This example espouses the same advice, but also introduces the concept of nesting one layout within another. E.G. the JPanel containing the JButtons has a GridLayout. That panel is placed in the NORTH of a panel that is then added to the WEST of the main ‘gui’ panel.

    The other components are added in order to show how the column of buttons might go together with other components in the main user interface.

    Contact.java

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    
    class Contact {
    
        public static void main(String[] args) {
            Runnable r = new Runnable() {
                public void run() {
                    JPanel gui = new JPanel(new BorderLayout(5,5));
                    gui.setBorder( new EmptyBorder(3,3,3,3) );
    
                    JPanel controls = new JPanel( new BorderLayout(5,5) );
    
                    JPanel buttons = new JPanel(new GridLayout(0,1,4,4));
                    buttons.add( new JButton("Show") );
                    buttons.add( new JButton("Add") );
                    buttons.add( new JButton("Update Number") );
                    buttons.add( new JButton("Delete") );
                    buttons.setBorder( new TitledBorder("Contact") );
    
                    controls.add( buttons, BorderLayout.NORTH );
    
                    controls.add(new JScrollPane(new JTree()), BorderLayout.CENTER);
    
                    gui.add(controls, BorderLayout.WEST);
    
                    gui.add(new JTextArea("CardLayout for CRUD components.",10,30));
    
                    gui.add(new JLabel("Output label.."), BorderLayout.SOUTH);
    
                    JToolBar toolbar = new JToolBar();
                    toolbar.add(new JCheckBox("Auto save", true));
                    toolbar.add(new JCheckBox("Always On Top"));
                    gui.add(toolbar, BorderLayout.NORTH);
    
                    JOptionPane.showMessageDialog(null, gui);
                }
            };
            SwingUtilities.invokeLater(r);
        }
    }
    

    Screenshot

    enter image description here

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

Sidebar

Related Questions

Check this screenshot here: http://farm6.static.flickr.com/5174/5389868759_8021dedbb8.jpg What are they utilizing to do that while loading
![enter image description here][1]On my two demo and screenshot, you can understand that so
Here's the deal: I'm in the process of planning a mid-sized business application that
Is all in the title, I do not understand the problem this time is
The idea is similar to the second screenshot here - except that app simply
when my application crashes, I see in call stack window that crash occured in
Here's a screenshot of what I'm dealing with: As you can see, the spacing
OK, here's a screenshot of what it's SUPPOSED to look like: And here's a
Here's how it looks like right now: my screenshot Is there a way for
Here's my proposed (very simplified to illustrate the problem space) design for a C#

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.