Commit 6b792e98 authored by 9731087's avatar 9731087

First Phase

parent bee67334
Pipeline #634 failed with stages
...@@ -10,13 +10,22 @@ public class ChatRoomGUI extends JFrame { ...@@ -10,13 +10,22 @@ public class ChatRoomGUI extends JFrame {
public ChatRoomGUI() { public ChatRoomGUI() {
super(); super();
this.setTitle(WINDOWS_TITLE); this.setTitle(WINDOWS_TITLE);
this.setLayout(null); this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WIDTH, HEIGHT); this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y); this.setLocation(X, Y);
this.setVisible(true); this.setVisible(true);
ChatArea chatBox = new ChatArea(); ChatArea chatBox = new ChatArea();
this.add(new JScrollPane(chatBox), BorderLayout.CENTER); this.add(new JScrollPane(chatBox), BorderLayout.CENTER);
MessageArea messageArea = new MessageArea();
this.add(messageArea, BorderLayout.SOUTH);
this.setVisible(true);
ParticipantsArea participantsArea = new ParticipantsArea();
this.add(participantsArea, BorderLayout.WEST);
participantsArea.addNewParticipant(" Amirmehdy");
participantsArea.addNewParticipant(" Abtin");
participantsArea.removeParticipant(" Amirmehdy");
this.setVisible(true);
} }
......
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
//System.out.println("Hello World!");
//UsernameFrame usernameFrame = new UsernameFrame();
ChatRoomGUI chatRoomGUI = new ChatRoomGUI(); ChatRoomGUI chatRoomGUI = new ChatRoomGUI();
UsernameFrame u = new UsernameFrame();
} }
} }
public class MessageArea { import javax.swing.*;
import java.awt.*;
public class MessageArea extends JPanel {
JTextField msg = new JTextField();
JTextField textField;
JButton btn;
private static final String BTN_TXT = "Send Message";
public MessageArea() {
super();
this.setLayout(new BorderLayout());
textField = new JTextField();
add(textField, BorderLayout.CENTER);
btn = new JButton(BTN_TXT);
add(btn, BorderLayout.EAST);
setVisible(true);
}
} }
public class ParticipantsArea { import javax.swing.*;
import java.awt.*;
public class ParticipantsArea extends JPanel {
public void addNewParticipant(String username) { private static final String LABEL_TXT = "Online People: ";
DefaultListModel model;
public ParticipantsArea() {
super();
this.setLayout(new BorderLayout());
JLabel label = new JLabel(LABEL_TXT);
add(label, BorderLayout.PAGE_START);
model = new DefaultListModel();
JList list = new JList(model);
add(list, BorderLayout.CENTER);
setVisible(true);
} }
public void removeParticipant(String username) { public void addNewParticipant(String username) {
model.addElement(username);
}
public void removeParticipant(String username) {
model.removeElement(username);
} }
} }
...@@ -11,11 +11,11 @@ public class UsernameFrame extends JFrame { ...@@ -11,11 +11,11 @@ public class UsernameFrame extends JFrame {
public UsernameFrame() throws HeadlessException { public UsernameFrame() throws HeadlessException {
super(); super();
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
JLabel label = new JLabel("Choose Your UserName"); JLabel label = new JLabel(LABEL_TXT);
add(label, BorderLayout.PAGE_START); add(label, BorderLayout.PAGE_START);
textField = new JTextField(); textField = new JTextField();
add(textField, BorderLayout.CENTER); add(textField, BorderLayout.CENTER);
btn = new JButton(LABEL_TXT); btn = new JButton(BTN_TXT);
add(btn, BorderLayout.PAGE_END); add(btn, BorderLayout.PAGE_END);
setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);
setVisible(true); setVisible(true);
......
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