Commit ed696f81 authored by Roonak's avatar Roonak

commiting

parents
Pipeline #637 failed with stages
package com.company;
import javax.swing.*;
import java.awt.*;
public class ChatArea extends JTextArea {
public ChatArea() {
super(10, 30);
this.setEditable(false);
this.setLineWrap(true);
addMessage("9687" , "gkrjk");
}
public void addMessage(String senderName, String message) {
this.append(senderName + ":" + message);
}
}
\ No newline at end of file
package com.company;
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(new BorderLayout());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
ChatArea chatBox = new ChatArea();
MessageArea message = new MessageArea();
ParticipantsArea participants = new ParticipantsArea();
add(chatBox, BorderLayout.CENTER);
add(message, BorderLayout.PAGE_END);
add(participants, BorderLayout.WEST);
this.setVisible(true);
}
}
\ No newline at end of file
package com.company;
public class Main {
public static void main(String[] args) {
ChatRoomGUI chatRoomGUI = new ChatRoomGUI();
}
}
package com.company;
import javax.swing.*;
import java.awt.*;
public class MessageArea extends JTextArea {
private final int WIDTH = 50, HEIGHT = 50;
private final int X = 100, Y = 100;
public MessageArea() {
super();
this.setLayout(new BorderLayout());
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
JTextField textField = new JTextField();
add(textField, BorderLayout.CENTER);
JButton button = new JButton("Send Message");
add(button, BorderLayout.EAST);
this.setVisible(true);
}
}
\ No newline at end of file
package com.company;
import javax.swing.DefaultListModel;
import javax.swing.*;
import java.awt.*;
public class ParticipantsArea extends JPanel {
private final int WIDTH = 50, HEIGHT = 50;
private final int X = 100, Y = 100;
DefaultListModel model;
public ParticipantsArea() {
super();
model = new DefaultListModel();
JList online = new JList(model);
this.setLayout(new BorderLayout());
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
JLabel label = new JLabel("onlineUsers");
add(label , BorderLayout.PAGE_START);
add(online, BorderLayout.CENTER);
addUser("Somayeh");
this.setVisible(true);
}
public void addUser(String userName){
model.addElement(userName);
}
public void removeUser(String userName){
model.removeElement(userName);
}
}
\ No newline at end of file
package com.company;
import javax.swing.*;
import java.awt.*;
class NameFrame 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 NameFrame() 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);
this.setLayout(new BorderLayout());
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