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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:17:41+00:00 2026-06-12T14:17:41+00:00

I want to make a JFrame to display a GUI like this: https://i.stack.imgur.com/2POFs.png (im

  • 0

I want to make a JFrame to display a GUI like this: https://i.stack.imgur.com/2POFs.png
(im not allowed to embed pictures)

the blank spcaces are the same X and Y dimentions,
the buttons are the same X and Y dimentions,
JTextArea is half of the frame.

public static JFrame frame = new JFrame ("Launcher " + version);
public static GridBagConstraints c = new GridBagConstraints();
public static JTextArea news = new JTextArea();
public static JButton launchGame = new JButton("Launch Game");
public static JButton settings = new JButton("Settings");
public static JButton exitGame = new JButton("Exit");

public static void main(String[] args) 
{
    news.setEditable(false);
    news.setBounds(0, 0, (screenSize.width - 500) / 2,  screenSize.height - 400);
    news.append("                        NEWS:\n");
    news.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, Color.black));

    frame.setLayout(new GridBagLayout());
    frame.setBounds(300, 200, screenSize.width - 500,  screenSize.height - 400);
    c.fill = GridBagConstraints.VERTICAL;
    c.weighty = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 3;
    frame.add(news, c);
    frame.setVisible(true);
    c.fill = GridBagConstraints.EAST;
    c.weightx = 0.5;
    c.gridx = 1;
    c.gridheight = 1;
    frame.add(launchGame, c);
    c.gridy = 1;
    frame.add(settings, c);
            c.gridy = 2;
    frame.add(exitGame, c);
}
  • 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-12T14:17:42+00:00Added an answer on June 12, 2026 at 2:17 pm

    Is this what you want? I added/modified the following in your button constraints:

        c.fill = GridBagConstraints.HORIZONTAL;
        c.insets = new Insets(0, 10, 0, 10); // 10 is the marginal
    

    And here is the full code:

    public static void main(String[] args)
    {
        news.setEditable(false);
        news.append("                        NEWS:\n");
        news.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, Color.black));
    
        frame.setLayout(new GridBagLayout());
        c.fill = GridBagConstraints.VERTICAL;
        c.weighty = 0.5;
        c.gridx = 0;
        c.gridy = 0;
        c.gridheight = 3;
        frame.add(news, c);
        c.fill = GridBagConstraints.HORIZONTAL;
        c.insets = new Insets(10, 10, 10, 10); // 10 is the marginal
        c.weightx = 0.5;
        c.gridx = 1;
        c.gridheight = 1;
        frame.add(launchGame, c);
        c.gridy = 1;
        frame.add(settings, c);
        c.gridy = 2;
        frame.add(exitGame, c);
    
        frame.pack();
        frame.setVisible(true);
    }
    

    Here is a similar layout using BoxLayout instead (easier to work with I think):

    private static JComponent buildButtons() {
        for (JButton button : Arrays.asList(launchGame, settings, exitGame)) {
            button.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        }
    
        Box b = Box.createVerticalBox();
        b.add(Box.createVerticalStrut(10));
        b.add(launchGame);
        b.add(Box.createVerticalStrut(10));
        b.add(settings);
        b.add(Box.createVerticalStrut(10));
        b.add(exitGame);
        b.add(Box.createVerticalStrut(10));
    
        return b;
    }
    
    static JComponent buildUI() {
        Box b = Box.createHorizontalBox();
        b.add(news);
        b.add(Box.createHorizontalStrut(10));
        b.add(buildButtons());
        b.add(Box.createHorizontalStrut(10));
    
        return b;
    }
    
    public static void main(String[] args)
    {
        news.setEditable(false);
        news.append("                        NEWS:\n");
        news.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, Color.black));
    
        frame.add(buildUI());
        frame.pack();
        frame.setVisible(true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make JFrame like JDialog box so user can not go outside
Layout is FreeDesign I want to make less space between JLabel and JFrame in
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I just met the utilities ( com.sun.awt.AWTUtilities ) to make your JFrame really transparent.
What I want is to make a new JFrame, keeping my current JFrame visible,
I have created a JFrame and want to hide this from the taskbar in
How to make JFrame transparent? I want to make my JFrame transparent. User should
I need to make a GUI Application for my class , so I want
I'm using Netbeans IDE to make a gui application. I have a JFrame with
I want to make working button and fit it in this code i have

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.