Commit bee67334 authored by 9731087's avatar 9731087

class created

parent 5bf65cc2
Pipeline #630 canceled with stages
public class ChatArea { import javax.swing.*;
public class ChatArea extends JTextArea {
private static final int ROWS = 10, COLUMNS = 30;
public ChatArea() {
super(ROWS, COLUMNS);
this.setEditable(false);
this.setLineWrap(true);
}
public void addMessage(String username, String message) {
String sb1 = username + ": " + message;
append(sb1);
}
} }
public class ChatRoomGUI { import javax.swing.*;
import java.awt.*;
public class ChatRoomGUI extends JFrame {
private final String WINDOWS_TITLE = "AUT Chat Room";
private final int WIDTH = 500, HEIGHT = 500;
private final int X = 100, Y = 100;
public ChatRoomGUI() {
super();
this.setTitle(WINDOWS_TITLE);
this.setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
this.setVisible(true);
ChatArea chatBox = new ChatArea();
this.add(new JScrollPane(chatBox), BorderLayout.CENTER);
}
} }
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello World!"); //System.out.println("Hello World!");
//UsernameFrame usernameFrame = new UsernameFrame();
ChatRoomGUI chatRoomGUI = new ChatRoomGUI();
} }
} }
public class ParticipantsArea { public class ParticipantsArea {
public void addNewParticipant(String username) {
}
public void removeParticipant(String username) {
}
} }
public class UsernameFrame { import javax.swing.*;
} import java.awt.*;
public class UsernameFrame extends JFrame {
private static final String BTN_TXT = " Start Chatting ...";
private static final String LABEL_TXT = " Choose Your UserName ";
private static final int WIDTH = 300, HEIGHT = 100;
JTextField textField;
JButton btn;
public UsernameFrame() throws HeadlessException {
super();
this.setLayout(new BorderLayout());
JLabel label = new JLabel("Choose Your UserName");
add(label, BorderLayout.PAGE_START);
textField = new JTextField();
add(textField, BorderLayout.CENTER);
btn = new JButton(LABEL_TXT);
add(btn, BorderLayout.PAGE_END);
setSize(WIDTH, HEIGHT);
setVisible(true);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment