Commit 80cd90f6 authored by Ali Shakoori's avatar Ali Shakoori

very first and last commit of lab10

parents
Pipeline #625 failed with stages
<?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="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</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$/GUI.iml" filepath="$PROJECT_DIR$/GUI.iml" />
</modules>
</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="3e3f8f75-1cc1-44c1-9cf5-886e47105746" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/out/" />
<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="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="45" selection-start-line="10" selection-start-column="45" selection-end-line="10" selection-end-column="45" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ChatRoomGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-67">
<caret line="16" selection-start-line="16" selection-end-line="16" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ParticipantArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="25" column="8" selection-start-line="25" selection-start-column="8" selection-end-line="25" selection-end-column="27" />
<folding>
<element signature="e#658#659#0" expanded="true" />
<element signature="e#692#693#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/MessageArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="13" selection-end-column="19" />
<folding>
<element signature="e#321#322#0" expanded="true" />
<element signature="e#347#348#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ChatArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="25" selection-start-line="9" selection-start-column="25" selection-end-line="9" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/UsernameFrame.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="21" selection-start-line="21" selection-end-line="21" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/Swing1.java" />
<option value="$PROJECT_DIR$/src/MyFrame.java" />
<option value="$PROJECT_DIR$/src/MessageArea.java" />
<option value="$PROJECT_DIR$/src/UsernameFrame.java" />
<option value="$PROJECT_DIR$/src/ParticipantArea.java" />
<option value="$PROJECT_DIR$/src/ChatArea.java" />
<option value="$PROJECT_DIR$/src/ChatRoomGUI.java" />
<option value="$PROJECT_DIR$/src/Main.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="85" />
<option name="y" value="25" />
<option name="width" value="1750" />
<option name="height" value="970" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="GUI" type="b2602c69:ProjectViewProjectNode" />
<item name="GUI" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1558308967212" />
<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" />
</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="RunManager" selected="Application.Main">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" />
<module name="GUI" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Swing1" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Swing1" />
<module name="GUI" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.Swing1" />
<item itemvalue="Application.Main" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
<item itemvalue="Application.Swing1" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="3e3f8f75-1cc1-44c1-9cf5-886e47105746" name="Default Changelist" comment="" />
<created>1557932202622</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1557932202622</updated>
<workItem from="1557932206877" duration="1259000" />
<workItem from="1558187714079" duration="10386000" />
<workItem from="1558252401668" duration="728000" />
<workItem from="1558308605387" duration="310000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="12683000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25973153" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3286119" />
<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="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="9" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Messages" order="11" />
<window_info anchor="right" id="Maven" />
<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" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Capture Analysis" order="4" />
<window_info anchor="right" id="Database" order="5" />
<window_info anchor="right" id="Theme Preview" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Maven Projects" order="8" />
</layout>
<layout-to-restore>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25302014" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32907802" />
<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="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="9" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Messages" order="11" />
<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" />
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Capture Analysis" order="4" />
<window_info anchor="right" id="Database" order="5" />
<window_info anchor="right" id="Theme Preview" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Maven Projects" order="8" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/Swing1.java" />
<entry file="file://$PROJECT_DIR$/src/MyFrame.java" />
<entry file="file://$PROJECT_DIR$/src/ParticipantArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="25" column="8" selection-start-line="25" selection-start-column="8" selection-end-line="25" selection-end-column="27" />
<folding>
<element signature="e#658#659#0" expanded="true" />
<element signature="e#692#693#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/MessageArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="13" selection-end-column="19" />
<folding>
<element signature="e#321#322#0" expanded="true" />
<element signature="e#347#348#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/UsernameFrame.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="21" selection-start-line="21" selection-end-line="21" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ChatArea.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="25" selection-start-line="9" selection-start-column="25" selection-end-line="9" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ChatRoomGUI.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-67">
<caret line="16" selection-start-line="16" selection-end-line="16" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="45" selection-start-line="10" selection-start-column="45" selection-end-line="10" selection-end-column="45" />
</state>
</provider>
</entry>
</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$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
import javax.swing.*;
import java.awt.*;
public class ChatArea extends JTextArea {
private static final int ROWS = 10 , COLUMN = 30;
public ChatArea(){
super(ROWS , COLUMN);
this.setEditable(false);
this.setLineWrap(true);
setVisible(true);
}
public void addMessage(String userName , String Message){
this.append(userName + " : " + Message + "\n");
}
}
import javax.swing.*;
import javax.swing.border.EtchedBorder;
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;
private ChatArea chatBox = new ChatArea();
private JPanel users = new JPanel();
private ParticipantArea user = new ParticipantArea();
private MessageArea messageArea = new MessageArea();
private JPanel msgArea = new JPanel();
public ChatRoomGUI(){
super();
this.setTitle(WINDOWS_TITLE);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WIDTH, HEIGHT);
this.setLocation(X, Y);
this.add(new JScrollPane().add(chatBox) ,BorderLayout.CENTER );
chatBox.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
users.setLayout(new BorderLayout());
users.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
users.add(user.getLabel() , BorderLayout.PAGE_START);
users.add(user.getList() , BorderLayout.CENTER);
this.add(users , BorderLayout.WEST);
msgArea.setLayout(new BorderLayout());
msgArea.add(new JScrollPane().add(messageArea) , BorderLayout.CENTER);
msgArea.add(messageArea.getBtn() , BorderLayout.EAST);
this.add(msgArea , BorderLayout.PAGE_END);
users.setVisible(true);
this.setVisible(true);
}
public void addNewMessage(String name , String message){
chatBox.addMessage(name , message);
}
public void addNewParticipant(String name){
user.addUser(name);
}
public Boolean removeParticipant(String name){
if(user.getListOfUsers().contains(name)){
user.getListOfUsers().removeElement(name);
return true;
}
else{
return false;
}
}
}
public class Main {
public static void main(String[] args) {
ChatRoomGUI chatRoom = new ChatRoomGUI();
chatRoom.addNewParticipant("Milad");
chatRoom.addNewParticipant("Ali");
chatRoom.addNewParticipant("Taghi");
chatRoom.addNewParticipant("Naghi");
chatRoom.addNewMessage("Milad" , "Hello Ali");
chatRoom.addNewMessage("Ali" , "Hello Taghi");
chatRoom.addNewMessage("Taghi" , "Hello Naghi");
chatRoom.addNewMessage("Naghi" , "Bye");
UsernameFrame user = new UsernameFrame();
}
}
import javax.swing.*;
public class MessageArea extends JTextField {
private JButton btn;
private final static String BTN_TXT = "Send";
public MessageArea(){
super();
btn = new JButton(BTN_TXT);
this.setEditable(true);
this.setVisible(true);
}
public JButton getBtn() {
return btn;
}
}
import javax.swing.*;
public class ParticipantArea extends JList {
private final static String LBL_TXT = "Online People: ";
private JLabel label;
private DefaultListModel<String> listOfUsers = new DefaultListModel<>();
private JList<String> list = new JList<>(listOfUsers);
public ParticipantArea(){
label = new JLabel(LBL_TXT);
this.setVisible(true);
}
public JLabel getLabel() {
return label;
}
public JList<String> getList() {
return list;
}
public void addUser(String name){
listOfUsers.addElement(name);
}
public DefaultListModel<String> getListOfUsers() {
return listOfUsers;
}
}
import javax.swing.*;
import java.awt.*;
public class UsernameFrame extends JFrame {
public static final String BTN_TXT = " Start Chatting ...";
public 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);
}
}
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