Commit 7d63cb76 authored by 9731087's avatar 9731087

Lab11 edition

parent 2daef90e
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="a77a824b-9ae2-4ac2-82a5-b8a8965212dd" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1680" />
<option name="height" value="934" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="src" type="b2602c69:ProjectViewProjectNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="editor.preferences.gutterIcons" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="a77a824b-9ae2-4ac2-82a5-b8a8965212dd" name="Default Changelist" comment="" />
<created>1558873172230</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1558873172230</updated>
<workItem from="1558873173569" duration="64000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="64000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1680" height="934" extended-state="0" />
<layout>
<window_info id="Image Layers" />
<window_info id="Designer" />
<window_info id="UI Designer" />
<window_info id="Capture Tool" />
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24969475" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Palette" />
<window_info anchor="right" id="Theme Preview" />
<window_info anchor="right" id="Maven" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="right" id="Palette&#9;" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>11</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
...@@ -6,6 +6,10 @@ public class ChatRoomGUI extends JFrame { ...@@ -6,6 +6,10 @@ public class ChatRoomGUI extends JFrame {
private final String WINDOWS_TITLE = "AUT Chat Room"; private final String WINDOWS_TITLE = "AUT Chat Room";
private final int WIDTH = 500, HEIGHT = 500; private final int WIDTH = 500, HEIGHT = 500;
private final int X = 100, Y = 100; private final int X = 100, Y = 100;
private ParticipantsArea participantsArea = new ParticipantsArea();
private ChatArea chatBox = new ChatArea();
private String username;
private MessageArea messageArea = new MessageArea(this);
public ChatRoomGUI() { public ChatRoomGUI() {
super(); super();
...@@ -15,20 +19,26 @@ public class ChatRoomGUI extends JFrame { ...@@ -15,20 +19,26 @@ public class ChatRoomGUI extends JFrame {
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();
this.add(new JScrollPane(chatBox), BorderLayout.CENTER); this.add(new JScrollPane(chatBox), BorderLayout.CENTER);
chatBox.addMessage(" Ostad", " Hello!");
MessageArea messageArea = new MessageArea();
this.add(messageArea, BorderLayout.SOUTH); this.add(messageArea, BorderLayout.SOUTH);
this.setVisible(true); this.setVisible(true);
ParticipantsArea participantsArea = new ParticipantsArea();
this.add(participantsArea, BorderLayout.WEST); this.add(participantsArea, BorderLayout.WEST);
participantsArea.addNewParticipant(" Amirmehdy");
participantsArea.addNewParticipant(" Abtin");
participantsArea.removeParticipant(" Amirmehdy");
participantsArea.addNewParticipant(" Ostad");
this.setVisible(true); this.setVisible(true);
} }
public void addParticipant(String name) {
this.participantsArea.addNewParticipant(name);
this.username = name;
}
public void addMessage(String text) {
this.chatBox.addMessage(username, " " + text + "\n");
this.messageArea.reset();
}
} }
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
ChatRoomGUI chatRoomGUI = new ChatRoomGUI(); // ChatRoomGUI chatRoomGUI = new ChatRoomGUI();
UsernameFrame u = new UsernameFrame(); UsernameFrame u = new UsernameFrame();
} }
......
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MessageArea extends JPanel { public class MessageArea extends JPanel {
JTextField msg = new JTextField(); JTextField msg = new JTextField();
JTextField textField; JTextField textField;
JButton btn; JButton btn;
private String username;
private static final String BTN_TXT = "Send Message"; private static final String BTN_TXT = "Send Message";
private ChatRoomGUI chatRoomGUI;
public MessageArea() { public MessageArea(ChatRoomGUI chatRoomGUI) {
super(); super();
this.chatRoomGUI = chatRoomGUI;
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
textField = new JTextField(); textField = new JTextField();
add(textField, BorderLayout.CENTER); add(textField, BorderLayout.CENTER);
btn = new JButton(BTN_TXT); btn = new JButton(BTN_TXT);
add(btn, BorderLayout.EAST); add(btn, BorderLayout.EAST);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doClickAction();
}
});
setVisible(true); setVisible(true);
} }
public void doClickAction() {
this.chatRoomGUI.addMessage(textField.getText());
}
public void reset(){
this.textField.setText("");
}
} }
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UsernameFrame extends JFrame { public class UsernameFrame extends JFrame {
private static final String BTN_TXT = " Start Chatting ..."; private static final String BTN_TXT = " Start Chatting ...";
...@@ -17,7 +19,18 @@ public class UsernameFrame extends JFrame { ...@@ -17,7 +19,18 @@ public class UsernameFrame extends JFrame {
add(textField, BorderLayout.CENTER); add(textField, BorderLayout.CENTER);
btn = new JButton(BTN_TXT); btn = new JButton(BTN_TXT);
add(btn, BorderLayout.PAGE_END); add(btn, BorderLayout.PAGE_END);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doClickAction();
}
});
setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);
setVisible(true); setVisible(true);
} }
public void doClickAction(){
ChatRoomGUI chatRoomGUI = new ChatRoomGUI();
chatRoomGUI.addParticipant(textField.getText());
this.setVisible(false);
}
} }
\ 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