Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save drelagreen/9a4a9d2cc8a7e52700b92d3044533b43 to your computer and use it in GitHub Desktop.
Save drelagreen/9a4a9d2cc8a7e52700b92d3044533b43 to your computer and use it in GitHub Desktop.
SAMBEKCHAT 1.1alpha
<component name="ArtifactManager">
<artifact type="jar" name="SambekChat:jar">
<output-path>$PROJECT_DIR$/out/artifacts/SambekChat_jar</output-path>
<root id="archive" name="SambekChat.jar">
<element id="module-output" name="SambekChat" />
</root>
</artifact>
</component>
<component name="ArtifactManager">
<artifact type="jar" name="ServerSambekChat">
<output-path>$PROJECT_DIR$/out/artifacts/ServerSambekChat</output-path>
<root id="archive" name="SambekChat.jar">
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/src/serverManifest/META-INF/MANIFEST.MF" />
</element>
<element id="module-output" name="SambekChat" />
</root>
</artifact>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="people" uuid="6b801a32-c9af-41d7-b92b-b3dc2ae695f8">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/res\people</jdbc-url>
<driver-properties>
<property name="enable_load_extension" value="true" />
</driver-properties>
</data-source>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/SambekChat.iml" filepath="$PROJECT_DIR$/SambekChat.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
<?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" />
<sourceFolder url="file://$MODULE_DIR$/res" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
package bin;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Graph extends JFrame {
JTextField jj;
Graph(){
setResizable(false);
setTitle(Kek.VERSION);
setSize(500,500);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JLabel label = new JLabel("Welcome to SAMBEKChat webEd(0.2b)");
label.setFont(new Font("Monaco", Font.PLAIN, 27));
JTextField login = new JTextField(10);
JPasswordField password = new JPasswordField(10);
JButton ok = new JButton("OK");
JButton cancel = new JButton("CANCEL");
setLocationRelativeTo(password);
JPanel panel1 = new JPanel();panel1.setLayout(new GridLayout(12,1));
panel1.setSize(500,500);
panel1.add(label);
panel1.add(new JLabel(" Login:"));
panel1.add(login);
panel1.add(new JLabel(" Password:"));
panel1.add(password);
// panel1.add(new JLabel(" IP:"));
// JTextField ipField = new JTextField(10);
// panel1.add(ipField);
panel1.add(ok);
panel1.add(cancel);
// ipField.setFont(new Font("Monaco", Font.PLAIN, 20));
login.setFont(new Font("Monaco", Font.PLAIN, 20));
password.setFont(new Font("Monaco", Font.PLAIN, 20));
jj = new JTextField(10);
panel1.add(jj);
jj.setEditable(false);
setContentPane(panel1);
ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!login.getText().equals("") &&password.getPassword()!=null/*&& !ipField.getText().equals("")*/)
Kek.login(login.getText(),password.getPassword(),"sambek.hopto.org"/* ipField.getText()*/);
if (Kek.isConnected) {jj.setText(":) Загрузка..."); Kek.turn2(); } else {
jj.setText(":( Подключение не удалось ");
}
ok.setEnabled(true);
cancel.setEnabled(true);
}
});
KeyListener kl = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==KeyEvent.VK_ENTER){
ok.doClick();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
};
// ipField.addKeyListener(kl);
password.addKeyListener(kl);
login.addKeyListener(kl);
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
}
package bin;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.StyledEditorKit;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import static java.awt.event.KeyEvent.VK_ENTER;
/**
* @author Drelgreen
* @// TODO: 16.10.2018 textArea1 - chat; textArea2 - mArea; textArea3 - info; b1 - button
*
*
*/
public class Graph2 extends Gu {
JDialog jDialog = new JDialog();
Graph2(){
textArea1.setAutoscrolls(true);
textArea1.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
}
});
setTitle(Kek.VERSION);
setVisible(true);
textArea1.setSize(1,1);
jScroll1.setAutoscrolls(true);
StyledEditorKit cl = new StyledEditorKit();
cl.install(textArea1);
setSize(610,650);
setBackground(new Color(0xB7F8AF));
setResizable(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
b1.addActionListener(event -> vector());
textArea2.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()== VK_ENTER&&!e.isShiftDown()){
b1.doClick();
}
if (e.getKeyCode()== VK_ENTER&&e.isShiftDown()){
textArea2.setText(textArea2.getText()+"\n");
}
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode()== VK_ENTER&&!e.isShiftDown()){
textArea2.setText(null);
}
}
});
this.setLocationRelativeTo(null);
}
private ArrayList<String> allTexts = new ArrayList<>();
public void print(String text) {
String s1 = " <head>\n" +
" \n" +
" </head>\n" +
" <body> \n";
String s2 = " </body>\n" +
"</html>\n";
allTexts.add(text+"\n");
StringBuilder messages = new StringBuilder();
for(Object theText : allTexts) {
messages.append("<p><font size=\"4\" face=\"Arial\">"+theText+"</font></p>\n");
}
textArea1.setText(s1+messages+"\n"+s2);
}
void print2(String text){
textArea3.setText(text);
}
public String writeM() {
String text;
text = textArea2.getText();
textArea2.setText(null);
return text;
}
public void vector() {
String text = writeM();
String[] t = text.split("");
if (t[0].equals("/")) {
String x = "";
for (int i = 1; i<t.length; i++){
x+=t[i];
}
sChecker(x);
} else {
print(Kek.nickname+" > "+text);
Kek.outToServer(text);
}
}
public void sChecker(String text){
}
// void mda(){
// progressBar1.setMaximum(10000);
//
// new Thread(() -> {
// while(true){
// if (progressBar1.getValue()==10000) progressBar1.setValue(0);
// progressBar1.setValue(progressBar1.getValue()+1);
// try {
// Thread.sleep(25);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }).start();
// }
}
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="bin.Gu">
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridBagLayout">
<constraints>
<xy x="120" y="32" width="579" height="433"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<grid id="f39e6" layout-manager="GridBagLayout">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="10.0" weighty="10.0"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<scrollpane id="451f" binding="jScroll1">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="7.0" weighty="7.0"/>
</constraints>
<properties>
<enabled value="true"/>
<horizontalScrollBarPolicy value="31"/>
<verticalScrollBarPolicy value="22"/>
</properties>
<border type="none"/>
<children>
<component id="d1f11" class="javax.swing.JEditorPane" binding="textArea1">
<constraints/>
<properties>
<background color="-1319"/>
<contentType value="text/html"/>
<editable value="false"/>
<font name="Times New Roman" size="20"/>
<foreground color="-65514"/>
</properties>
</component>
</children>
</scrollpane>
<component id="32757" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
</children>
</grid>
<grid id="1ef9a" layout-manager="GridBagLayout">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="10.0"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<component id="34bd5" class="javax.swing.JTextPane" binding="textArea3">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
<gridbag weightx="1.0" weighty="1.0"/>
</constraints>
<properties>
<background color="-4893"/>
<font name="Comic Sans MS" size="12" style="3"/>
</properties>
</component>
<component id="f5b26" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
<component id="84eb7" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
<component id="a32b8" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
</children>
</grid>
<grid id="7c003" layout-manager="GridBagLayout">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="4.0"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="29903">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="1.0"/>
</constraints>
<properties>
<horizontalScrollBarPolicy value="31"/>
<verticalScrollBarPolicy value="22"/>
</properties>
<border type="none"/>
<children>
<component id="8c3a2" class="javax.swing.JEditorPane" binding="textArea2">
<constraints/>
<properties>
<background color="-1319"/>
<font name="Times New Roman" size="14"/>
</properties>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="1dd62" layout-manager="GridBagLayout">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<component id="5947d" class="javax.swing.JButton" binding="b1">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<background color="-13262081"/>
<font name="Consolas" size="16" style="1"/>
<foreground color="-2887171"/>
<text value="&gt;&gt;"/>
</properties>
</component>
</children>
</grid>
<grid id="70c25" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="4.0"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="4dd40" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="1.0" weighty="10.0"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<component id="e86a2" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2887171"/>
<text value=" "/>
</properties>
</component>
</children>
</grid>
<grid id="ba0eb" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.1"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<component id="f611a" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
</children>
</grid>
<grid id="3aa4a" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.1"/>
</constraints>
<properties>
<background color="-2887171"/>
</properties>
<border type="none"/>
<children>
<component id="cf931" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=" "/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
package bin;
import javax.swing.*;
import javax.swing.text.rtf.RTFEditorKit;
public class Gu extends JFrame {
Gu(){
getContentPane().add(panel1);
setVisible(true);
}
private JPanel panel1;
public JEditorPane textArea1;
public JEditorPane textArea2;
public JTextPane textArea3;
public JButton b1;
public JScrollPane jScroll1;
}
package bin;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Arrays;
public class Kek {
public static final String VERSION = "SAMBEKChat v1.0b";
static volatile Graph2 g2;
static String nickname = "Test";
static Socket socket;
static DataInputStream dataInputStream;
static DataOutputStream dataOutputStream;
static boolean isConnected = false;
static Graph g = new Graph();
public static void main(String[] args) {
}
public static void login(String log, char[] pas, String ip){
System.out.println(log);
for (char c : pas) {
System.out.println(c);
}
int hash = Arrays.hashCode(pas);
System.out.println(hash);
try {
socket = new Socket(ip,7788);
dataInputStream = new DataInputStream(socket.getInputStream());
dataOutputStream = new DataOutputStream(socket.getOutputStream());
dataOutputStream.writeUTF(log+":"+hash);
isConnected = dataInputStream.readBoolean();
if(!isConnected){socket = null; dataInputStream = null; dataOutputStream = null;}
} catch (IOException e) {
isConnected = false;
}
}
public static void turn2(){
g2 = new Graph2();
System.out.println("OK");
g.setVisible(false);
g2.textArea1.setEditable(false);
g2.textArea3.setEditable(false);
sCom();
// g2.mda();
}
public static void sCom(){
new Thread(() -> {
while (true){
try {
String s = dataInputStream.readUTF();
System.out.println("new email");
String t[] = s.split("");
switch (t[0]){
case ("1"):
StringBuilder x = new StringBuilder();
t[0]="";
for (String s1 : t) {
x.append(s1);
}
g2.print(x.toString());
break;
case ("3"):
StringBuilder y = new StringBuilder();
t[0]="";
for (String s1 : t) {
y.append(s1);
}
g2.print2(y.toString());
break;
case "N":
StringBuilder z = new StringBuilder();
t[0]="";
for (String s1 : t) {
z.append(s1);
}
nickname = z.toString();
break;
}
} catch (IOException e) {
e.printStackTrace();
break;
}
}
}).start();
}
public static void outToServer(String text){
try {
dataOutputStream.writeUTF(text);
System.out.println(text);
dataOutputStream.flush();
} catch (IOException e) {
g2.print2("SERVERERROR");
// g2.progressBar1.setVisible(false);
}
}
}
package bin;
public class Test {
public static void main(String[] args) {
Kek.turn2();
}
}
Manifest-Version: 1.0
Main-Class: bin.Kek
package servBin;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class Server1 {
static volatile Map<String, Integer> clients = new HashMap<>();
static volatile ArrayList<T> online = new ArrayList<>();
static volatile ServerSocket serverSocket;
public static void main(String[] args) throws IOException {
char[] c = {'4','6','5','4'};
char[] c3 = {'5','2','2','5'};
System.out.println(Arrays.hashCode(c));
char[] c1 = {'1','2','3','4'};
char[] c2 = {'1','1','3','4'};
clients.put("Dimon", Arrays.hashCode(c));
clients.put("Pukich", Arrays.hashCode(c3));
clients.put("Kakich", Arrays.hashCode(c1));
clients.put("HehMdaHmm", Arrays.hashCode(c2));
kek();
}
static void newConnect(String nick){
sendMessage("<h2>! > "+nick , "/вошёл в чат!/</h2>");
sendMessage3("!theOnline");
}
static void offConnect(T t, String nick){
System.out.println("htoto otletel (2)");
for (int i = 0; i < online.size(); i++) {
if (online.get(i).nick.equals(nick)) {
online.remove(i);
t.hmm = false;
t.socket = null;
t.interrupt();
sendMessage3("!theOnline");
sendMessage("<font size = \"6\">! > "+nick, "/отлетел!/ </font>");
}
}
}
static void sendMessage3(String m){
if (m.equals("!theOnline")){
StringBuilder x= new StringBuilder();
x.append("ONLINE:\n");
for (T t : online) {
x.append(t.nick);
x.append("\n");
}
for (T t : online) {
t.sMessage("3"+x.toString());
}
}
}
static void sendMessage(String nick, String m){
System.out.println(m);
if (online.size()!=0)
for (int i = 0; i < online.size(); i++) {
if (!online.get(i).isInterrupted())
if (!online.get(i).nick.equals(nick))
online.get(i).sMessage("1"+nick+" > "+m);
}
}
static void cmd(String com){
}
static void kek() throws IOException {
serverSocket = new ServerSocket(7788);
while (true) {
try {
System.out.println("&");
T t = new T(serverSocket.accept());
t.start();
System.out.println("+1");
} catch (IOException e) {
e.printStackTrace();
System.out.println("/kek/ error");
break;
}
}
}
}
package servBin;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
class T extends Thread{
Boolean hmm = false;
Socket socket;
String nick;
DataInputStream dataInputStream;
DataOutputStream dataOutputStream;
T(Socket socket){
this.socket=socket;
}
@Override
public void run() {
try {
dataInputStream = new DataInputStream(socket.getInputStream());
dataOutputStream = new DataOutputStream(socket.getOutputStream());
String welcome = dataInputStream.readUTF();
String w1[] = welcome.split(":");
String[] x = w1[1].split("");
if (Server1.clients.get(w1[0])==Integer.parseInt(w1[1])){
System.out.println(w1[0]+"n"+w1[1]);
dataOutputStream.writeBoolean(true);
for (int i = 0; i < Server1.online.size(); i++) {
if (Server1.online.get(i).nick.equals(w1[1])){
dataOutputStream.writeBoolean(false);
throw new IOException();
}
}
nick = w1[0];
dataOutputStream.writeUTF("N"+nick);
Server1.online.add(this);
inMessageDaemon();
hmm=true;
Server1.newConnect(nick);
} else {
System.out.println("wrongPass! de pas is - " + Server1.clients.get(w1[0]) + " but " + w1[1]);
dataOutputStream.writeBoolean(false);
}
} catch (IOException e) {
System.out.println("htoto otletel");
e.printStackTrace();
if (hmm)
Server1.offConnect(this, nick);
}
}
public void sMessage(String m){
try {
dataOutputStream.writeUTF(m);
System.out.println(m);
} catch (IOException e) {
if(hmm) {
System.out.println("htoto otletel");
e.printStackTrace();
Server1.offConnect(this, nick);
}
}
}
public void inMessageDaemon(){
new Thread(()->{
while (true){
try {
String m = dataInputStream.readUTF();
Server1.sendMessage(nick, m);
} catch (IOException e) {
System.out.println("htoto otletel");
e.printStackTrace();
Server1.offConnect(this, nick);
break;
}
}
}).start();
}
}
Manifest-Version: 1.0
Main-Class: servBin.Server1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment