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

The Archive Base Latest Questions

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

I am working on a Java project for college that involves us setting up

  • 0

I am working on a Java project for college that involves us setting up a TCP Server and Client. I have that part working and now to add more of a feel to my project I want to add a GUI.

We have not begun learning about GUI’s in Java yet. However I want to try as I think it would be a useful exercise. I have a very basic GUI set up and the appropriate ActionListener set for the button. My next problem is positioning my panels so they look neat and tidy on the Frame…

At the moment I have all the components in one panel as seen below:

public ClientGUI(){

    //Initialise Frame
    frame = new JFrame("TCP Client");

    //Initialise Panel 1 & Components
    p1 = new JPanel();

    //Set Layout
    p1.setLayout(new GridLayout(1,2));

    //Label 1 - For TextArea
    l1 = new JLabel("Chat Log");
    p1.add(l1);

    //TextArea - To display conversation
    t1 = new JTextArea(10,10);
    p1.add(t1);

    //Label 2 - For TextField
    l2 = new JLabel("Message");
    p1.add(l2);

    //Message Box - For user input
    t2 = new JTextField(10);
    p1.add(t2);

    //Button 1 - To send message
    b1 = new JButton("Send");
    p1.add(b1);

    //Add panels to frame
    frame.add(p1);

    //Frame properties...
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400,400);
    frame.setVisible(true);

    //Add Event listener to button
    b1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ev){
            //do something
            t1.setText(t2.getText());
        }
    });

I would love for it to look something like the rough wireframe below.

Desired Layout

I’d appreciate any feedback anyone might have! Thanks very much.

  • 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-13T09:42:33+00:00Added an answer on June 13, 2026 at 9:42 am

    What you want is called the BoxLayout, which feeds UI elements in columns or rows. And then you can nest them one inside another, e.g. have one horizontal box layout panel as an element in another that is vertical (kind of like nested HTML tables). So all of your elements would go in a top level vertical BoxLayout and the line that has JLabel2 and JTextField would be its own horizontal BoxLayout nested in the top level vertical layout. Here is a pretty decent tutorial about layout managers and it includes the BoxLayout.

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

Sidebar

Related Questions

I'm working on a Java project where I have created a class that looks
I'm working on a java project full of Hibernate (3.3.1) mapping files that have
I'm working on a java project, and now I have been asked to track
I'm working on a Java project that involves retrieving a large amount of images
I'm working on a java project that will allows users to parse multiple files
I am working on a Java project and need to have a keypress simulate
I'm currently working on a java project that requires me to make a system
I`m an Android developer, and recently started working on JAVA PC project for client.
I'm working on code for a Java project, I currently have replaceAll(String, int) in
I am working on a project for college that uses GWT, Hibernate and Gilead.

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.