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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:10:10+00:00 2026-05-16T22:10:10+00:00

I’m currently enrolled in a Client/Server Programming class (i.e. Java 2) in college. For

  • 0

I’m currently enrolled in a Client/Server Programming class (i.e. Java 2) in college. For our first lab assignment, we’re being asked to create a simple GUI to emulate a basic instant messaging chat client. This client won’t have any actual functionality, just a simple window. This window, however has to look similar to a window developed by my professor for a Visual Basic class. Now, I KNOW that with my basic knowledge, I’ll never be able to get my code to look exactly like the example, but I’d like to get as close as possible.

My real question is: what LayoutManager (or combination thereof) should I be using to get as close to this as possible? I’ve only put in the first couple components onto my lab project, but I’m curious if I’m doing this right… Or if I’m using the smartest approach. Thanks for any and all help!

EDIT: OH, before I forget, here’s the sample code that I already have now. Pick it apart at your leisure! Any and all criticisms are welcome, both for my code, and the approach I’ve tried!

import java.awt.*;
import javax.swing.*;

public class Chat {
    public static void main(String[] args) {
        /*
         * The main() method is what creates the Frame for use by the user. It set's a default size to 300x600,
         * which is a pretty standard size for a chat client. It also adds a title to the Frame, which adds a
         * cool element there!
         */
        ChatClient GUI = new ChatClient();
        GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GUI.setSize(300, 600);
        GUI.setTitle("Lab 1: Chat");
        GUI.setVisible(true);
        GUI.start();
    }
}

class ChatClient extends JFrame {
    public void start() {
        setLayout(new BorderLayout());

        /*
         * Divide the main Frame into three separate Panels. The North Panel holds the username, server, and port
         * information, along with the associated Buttons.
         */

        JPanel northPanelGroup = new JPanel(new GridLayout(3, 3, 1, 1));
        JPanel centerPanelGroup = new JPanel(new GridLayout(1, 1, 1, 1));
        JPanel southPanelGroup = new JPanel(new GridLayout(1, 3, 1, 1));

        /*
         * Obviously, add the Panel Groups into the main Frame
         */
        add(BorderLayout.NORTH, northPanelGroup);
        add(BorderLayout.CENTER, centerPanelGroup);
        add(BorderLayout.SOUTH, southPanelGroup);

        /*
         * Begin adding the username, server, and port information into the North Panel
         */
        JPanel usernamePanel = new JPanel();
        usernamePanel.add(new JLabel("Username"));
        usernamePanel.add(new JTextField(10));
        northPanelGroup.add(usernamePanel);

        JPanel serverPanel = new JPanel();
        serverPanel.add(new JLabel("Server"));
        serverPanel.add(new JTextField(10));
        northPanelGroup.add(serverPanel);

        JPanel portPanel = new JPanel();
        portPanel.add(new JLabel("Port"));
        portPanel.add(new JTextField(5));
        northPanelGroup.add(portPanel);
    }
}
  • 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-16T22:10:11+00:00Added an answer on May 16, 2026 at 10:10 pm

    You should use Mattise in Netbeans IDE if you’re having trouble with GUI creation 🙂 Honestly though, if you want to do it programatically, you should have a look at MigLayout ( http://www.miglayout.com/ ) which is the easiest and most flexible layout manager going.

    http://blogs.sun.com/roumen/resource/matisse6.PNG

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am currently running into a problem where an element is coming back from
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have thousands of HTML files to process using Groovy/Java and I need to

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.