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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:49:42+00:00 2026-06-13T16:49:42+00:00

I am creating a program which has three jpanels: one container, and inside the

  • 0

I am creating a program which has three jpanels: one container, and inside the container is two jpanels, one that is going to hold buttons and one which will hold the content. Ive got them both showing so far and its looking good, the only problem i I was hoping to add some space or a border between or the two (or around the button menu if possible) however since both internal panels are set to null layouts and the external layout is set to a border layout I cannot seem to add a border between the two internal ones. Here is my code so far:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class internal_test extends JFrame {

int height = 480;
int width = 640;

public internal_test() {
    initUI();
}

private void initUI() {

    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);

    JPanel buttonMenu = new JPanel();
    buttonMenu.setLayout(null);
    buttonMenu.setBackground(Color.DARK_GRAY);
    buttonMenu.setPreferredSize(new Dimension(150, height));

    JPanel dragFrame = new JPanel();
    dragFrame.setLayout(null);
    dragFrame.setPreferredSize(new Dimension(200, 100));
    dragFrame.setSize(new Dimension(490, height));
    dragFrame.setBackground(Color.gray);

    container.add(buttonMenu, BorderLayout.WEST);
    container.add(dragFrame, BorderLayout.CENTER);

    // container.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));

    add(container);
    pack();

    setTitle("internal_test V0.1");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(width, height);
    setLocationRelativeTo(null);
}

public static void main(String args[]) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            internal_test c = new internal_test();

            c.setVisible(true);

        }
    });
}

}

The dragFrame is going to be a DragLayout since that layout does what I need it to, but the button menu could technically be any layout, as long as it would allow me to place buttons/other items in a list with a label next to each.

Any help is greatly appreciated.

  • 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-13T16:49:44+00:00Added an answer on June 13, 2026 at 4:49 pm

    This should help you add the type of border you want:
    http://docs.oracle.com/javase/tutorial/uiswing/components/border.html

    You can start with a red line border like this:
    buttonMenu.setBorder(BorderFactory.createLineBorder(Color.red));

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

Sidebar

Related Questions

I am creating a program which has an installer-like interface. Is it better to
I am creating a client program that talks to a server (which I programmed).
Here's a Windows Forms program which draws a two-dimensional grid of squares that are
I am currently making a program (C# .Net 4) that has multiple options, which
I creating a program which send newsletter with a background image. It works fine
i am creating a bluetooth based server program in Bluez which basically handles connections
I'm creating an about JFrame for my program. I have an icon which I
Bassicly im creating a program that reads information from an xml file into a
I'm creating a program in VB.NET to output multiple images. Some images will have
I have a large old program which has some rather complex graphical displays (all

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.