summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/ChatClientCMD.java (renamed from src/javaChat/ChatClient.java)4
-rw-r--r--src/backend/ChatServer.classbin0 -> 1638 bytes
-rw-r--r--src/backend/ChatServer.java309
-rw-r--r--src/backend/ClientHandler.classbin0 -> 4117 bytes
-rw-r--r--src/chatApp/ChatGUI$1.classbin0 -> 570 bytes
-rw-r--r--src/chatApp/ChatGUI$2.classbin0 -> 573 bytes
-rw-r--r--src/chatApp/ChatGUI$3.classbin0 -> 455 bytes
-rw-r--r--src/chatApp/ChatGUI.classbin0 -> 6647 bytes
-rw-r--r--src/chatApp/ChatGUI.java167
-rw-r--r--src/chatApp/ChattingUI$1.classbin0 -> 585 bytes
-rw-r--r--src/chatApp/ChattingUI$2.classbin0 -> 588 bytes
-rw-r--r--src/chatApp/ChattingUI$3.classbin0 -> 464 bytes
-rw-r--r--src/chatApp/ChattingUI.classbin0 -> 6665 bytes
-rw-r--r--src/chatApp/ClientGUI$1.classbin0 -> 1440 bytes
-rw-r--r--src/chatApp/ClientGUI$2.classbin0 -> 884 bytes
-rw-r--r--src/chatApp/ClientGUI.classbin0 -> 2154 bytes
-rw-r--r--src/chatApp/ClientGUI.java (renamed from src/javaChat/ClientGUI.java)60
-rw-r--r--src/chatApp/LoginGUI$1.classbin0 -> 578 bytes
-rw-r--r--src/chatApp/LoginGUI$2.classbin0 -> 578 bytes
-rw-r--r--src/chatApp/LoginGUI$3.classbin0 -> 458 bytes
-rw-r--r--src/chatApp/LoginGUI$4.classbin0 -> 575 bytes
-rw-r--r--src/chatApp/LoginGUI$5.classbin0 -> 575 bytes
-rw-r--r--src/chatApp/LoginGUI$6.classbin0 -> 458 bytes
-rw-r--r--src/chatApp/LoginGUI.classbin0 -> 6098 bytes
-rw-r--r--src/chatApp/LoginGUI.java182
-rw-r--r--src/chatApp/loginDEMO$1.classbin0 -> 583 bytes
-rw-r--r--src/chatApp/loginDEMO$2.classbin0 -> 461 bytes
-rw-r--r--src/chatApp/loginDEMO.classbin0 -> 5624 bytes
-rw-r--r--src/demonstration/ChatDEMO$1.classbin0 -> 599 bytes
-rw-r--r--src/demonstration/ChatDEMO$2.classbin0 -> 602 bytes
-rw-r--r--src/demonstration/ChatDEMO$3.classbin0 -> 470 bytes
-rw-r--r--src/demonstration/ChatDEMO.classbin0 -> 6683 bytes
-rw-r--r--src/demonstration/ChatDEMO.java166
-rw-r--r--src/demonstration/ClientDEMO$1.classbin0 -> 1469 bytes
-rw-r--r--src/demonstration/ClientDEMO$2.classbin0 -> 913 bytes
-rw-r--r--src/demonstration/ClientDEMO.classbin0 -> 2208 bytes
-rw-r--r--src/demonstration/ClientDEMO.java110
-rw-r--r--src/demonstration/LoginDEMO$1.classbin0 -> 607 bytes
-rw-r--r--src/demonstration/LoginDEMO$2.classbin0 -> 473 bytes
-rw-r--r--src/demonstration/LoginDEMO.classbin0 -> 6086 bytes
-rw-r--r--src/demonstration/LoginDEMO.java158
-rw-r--r--src/javaChat/ChatServer.java237
-rw-r--r--src/javaChat/UserInterface.java288
43 files changed, 1130 insertions, 551 deletions
diff --git a/src/javaChat/ChatClient.java b/src/backend/ChatClientCMD.java
index 9560b49..dbaa391 100644
--- a/src/javaChat/ChatClient.java
+++ b/src/backend/ChatClientCMD.java
@@ -1,4 +1,4 @@
-package javaChat;
+package backend;
import java.net.* ;
@@ -6,7 +6,7 @@ import javax.swing.JFrame ;
import java.io.* ;
-public class ChatClient
+public class ChatClientCMD
{
/**
diff --git a/src/backend/ChatServer.class b/src/backend/ChatServer.class
new file mode 100644
index 0000000..f3ea427
--- /dev/null
+++ b/src/backend/ChatServer.class
Binary files differ
diff --git a/src/backend/ChatServer.java b/src/backend/ChatServer.java
new file mode 100644
index 0000000..c8ebfef
--- /dev/null
+++ b/src/backend/ChatServer.java
@@ -0,0 +1,309 @@
+
+package backend ;
+
+import java.io.DataInputStream ;
+import java.io.DataOutputStream ;
+import java.io.IOException ;
+import java.net.ServerSocket ;
+import java.net.Socket ;
+import java.util.ArrayList ;
+
+/**
+ * ChatServer class accepts Client requests to join
+ * and creates an individual thread for each client.
+ * The "brain" of the server.
+ *
+ * @author osheas1
+ * @author gohringj
+ * @version Semi-Final Draft
+ */
+public class ChatServer
+ {
+
+ // List of all active users in Server
+ public static ArrayList<ClientHandler> userList = new ArrayList<>() ;
+
+
+ /**
+ * @param args (unused)
+ * @throws IOException (is thrown if connection is unexpectedly closed)
+ */
+ public static void main( final String[] args ) throws IOException
+ {
+ // Register service on port 6789
+ ServerSocket serverSocket = new ServerSocket( 6789 ) ;
+ Socket socket = null ;
+
+ System.out.println( "\nServer established. Awaiting connections..." ) ;
+
+ // Loop to accept client requests
+ while ( true )
+ {
+ socket = serverSocket.accept() ;
+
+ DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ;
+ DataInputStream dataStreamIn = new DataInputStream( socket.getInputStream() ) ;
+
+ System.out.println( "\nClient connection detected, requesting username..." ) ;
+ String username = dataStreamIn.readUTF() ;
+
+ ClientHandler handle = new ClientHandler( socket, username, dataStreamOut, dataStreamIn ) ;
+
+ System.out.println( "\nCreating new thread...\n" ) ;
+ Thread thread = new Thread( handle ) ;
+
+ userList.add( handle ) ;
+
+ thread.start() ;
+ }
+ }
+ } // end class ChatServer
+
+
+
+
+/**
+ * ClientHandler class manages the actual messages being sent
+ * between the users. The "heart" of the server.
+ *
+ * @author osheas1
+ * @author gohringj
+ * @version Semi-Final Draft
+ */
+
+class ClientHandler implements Runnable
+ {
+ Socket socket ;
+ String username ;
+ DataOutputStream dataStreamOut ;
+ DataInputStream dataStreamIn ;
+ boolean loggedIn ;
+ int commandCheck ;
+
+ /**
+ * Constructor
+ * @param s = client socket
+ * @param user = client's user-name
+ * @param dos = data stream to client
+ * @param dis = data stream from client
+ */
+ public ClientHandler( Socket s, String user, DataOutputStream dos, DataInputStream dis )
+ {
+ this.socket = s ;
+ this.username = user ;
+ this.dataStreamOut = dos ;
+ this.dataStreamIn = dis ;
+ this.loggedIn = true ;
+ }
+
+
+ @Override
+ public void run()
+ {
+ // Note the connection of the new user
+ String announcement = String.format( "\n>>> User \"%s\" has successfully connected (type /help for a list of commands) <<<\n", this.username ) ;
+ System.out.println( announcement ) ;
+
+ // Distribute announcement to entire server
+ sendMessage( announcement ) ;
+
+ // Message management
+ String message = "" ;
+ while ( true )
+ {
+ // Try-Catch block interprets incoming messages
+ try
+ {
+ message = this.dataStreamIn.readUTF() ;
+
+ if(message == "" || message == " ")
+ {
+ continue ;
+ }
+ }
+ catch ( IOException x )
+ {
+ x.printStackTrace() ;
+ }
+
+ // Check message for user commands, returns TRUE if user "/quit"s
+ if( commands( message, this ) )
+ {
+ break ;
+ }
+
+ // Print the message server-side
+ message = String.format( "%s: %s", this.username, message ) ;
+ System.out.println( message ) ;
+
+ // Distribute the message to all users
+ if ( this.commandCheck == 0 )
+ {
+ sendMessage( message ) ;
+ }
+ else
+ {
+ this.commandCheck = 0 ;
+ }
+ } // end while
+
+ // close streams when user disconnects
+ try
+ {
+ this.loggedIn = false ;
+ this.dataStreamIn.close() ;
+ this.dataStreamOut.close() ;
+ this.socket.close() ;
+ }
+ catch ( IOException x )
+ {
+ x.printStackTrace() ;
+ }
+ } // end run
+
+
+ /**
+ * The 'commands' method manages the usage of user-commands
+ * by distributing private messages, providing a user-list,
+ * etc.
+ *
+ * @param message = the command itself
+ * @param user = the user that
+ * @return = boolean that indicates that the user has disconnected
+ */
+ public boolean commands( String message, final ClientHandler user )
+ {
+ final String[] commands = new String[] { "/help", "/quit", "/userlist", "/pm" } ;
+
+ try
+ {
+ // Quit command terminates client's connection, with an announcement
+ if ( message.equals( "/quit" ) )
+ {
+ this.commandCheck++ ;
+ String announcement = String.format( "\n-= \"%s\" has disconnected =- \n", user.username ) ;
+ System.out.println( announcement ) ;
+ sendMessage( announcement ) ;
+ return true ;
+ }
+
+ // User-List command provides the user a list of everyone else connected to the server
+ if ( message.equals( "/userlist" ) )
+ {
+ this.commandCheck++ ;
+ user.dataStreamOut.writeUTF( "> Current list of users in the server: " ) ;
+ for ( ClientHandler users : ChatServer.userList )
+ {
+ if ( !users.loggedIn )
+ {
+ continue ;
+ }
+
+ user.dataStreamOut.writeUTF( "> " + users.username ) ;
+ }
+ }
+
+ // Help command lists all available commands
+ if ( message.equals( "/help" ) )
+ {
+ this.commandCheck++ ;
+ user.dataStreamOut.writeUTF( "\n> All available commands: " ) ;
+ for ( String command : commands )
+ {
+ user.dataStreamOut.writeUTF( "> " +command ) ;
+ }
+
+ user.dataStreamOut.writeUTF( "\n" ) ;
+ }
+
+ // Private Message Command allows users to send messages to a single recipient
+ if ( message.contains( "/pm" ) )
+ {
+ this.commandCheck++ ;
+ user.dataStreamOut.writeUTF( "\n> Who would you like to private message?" ) ;
+ String recipient = this.dataStreamIn.readUTF() ;
+ user.dataStreamOut.writeUTF( "> \"" + recipient + "\"" ) ;
+
+ ClientHandler sendTo = null ;
+
+ // loop determines which ClientHandler object to send the message to
+ for ( ClientHandler users : ChatServer.userList )
+ {
+ if ( !users.loggedIn )
+ {
+ continue ;
+ }
+ else if ( users.username.equals( recipient ) )
+ {
+ sendTo = users ;
+ }
+ }
+
+ if ( sendTo == null )
+ {
+ user.dataStreamOut.writeUTF( "\n> User not found, please try again" ) ;
+ return false ;
+ }
+
+ user.dataStreamOut.writeUTF( "\n> What would you like to say?" ) ;
+ String privateMessage = this.dataStreamIn.readUTF() ;
+ user.dataStreamOut.writeUTF( "> sent: \"" + privateMessage + "\"" ) ;
+ sendPrivateMessage( privateMessage, user.username, sendTo ) ;
+
+ }
+ }
+
+ catch ( IOException x )
+ {
+ while ( ChatServer.userList.size() != 0 )
+ {
+ System.out.println( x ) ;
+ }
+ }
+
+ return false ;
+ } // end commands
+
+
+ // Convenience method to send messages privately
+ private static void sendPrivateMessage( String message, final String sentfrom, final ClientHandler sendto )
+ {
+ try
+ {
+ for ( ClientHandler users : ChatServer.userList )
+ {
+ if ( users.equals( sendto ) )
+ {
+ message = String.format( "\nFrom <%s>: %s", sentfrom, message ) ;
+ users.dataStreamOut.writeUTF( message ) ;
+ }
+ }
+ }
+ catch ( final IOException x )
+ {
+ x.printStackTrace() ;
+ }
+ }
+
+
+ // Convenience method to distribute messages to all clients
+ private static void sendMessage( String message )
+ {
+ try
+ {
+ for ( ClientHandler users : ChatServer.userList )
+ {
+ if ( !users.loggedIn )
+ {
+ continue ;
+ }
+ users.dataStreamOut.writeUTF( message ) ;
+ }
+ }
+ catch ( IOException x )
+ {
+ x.printStackTrace() ;
+ }
+ }
+ }
+// end class ClientHandler \ No newline at end of file
diff --git a/src/backend/ClientHandler.class b/src/backend/ClientHandler.class
new file mode 100644
index 0000000..d0dbaf0
--- /dev/null
+++ b/src/backend/ClientHandler.class
Binary files differ
diff --git a/src/chatApp/ChatGUI$1.class b/src/chatApp/ChatGUI$1.class
new file mode 100644
index 0000000..af760ba
--- /dev/null
+++ b/src/chatApp/ChatGUI$1.class
Binary files differ
diff --git a/src/chatApp/ChatGUI$2.class b/src/chatApp/ChatGUI$2.class
new file mode 100644
index 0000000..9c726a5
--- /dev/null
+++ b/src/chatApp/ChatGUI$2.class
Binary files differ
diff --git a/src/chatApp/ChatGUI$3.class b/src/chatApp/ChatGUI$3.class
new file mode 100644
index 0000000..6c7c945
--- /dev/null
+++ b/src/chatApp/ChatGUI$3.class
Binary files differ
diff --git a/src/chatApp/ChatGUI.class b/src/chatApp/ChatGUI.class
new file mode 100644
index 0000000..72f3bc7
--- /dev/null
+++ b/src/chatApp/ChatGUI.class
Binary files differ
diff --git a/src/chatApp/ChatGUI.java b/src/chatApp/ChatGUI.java
new file mode 100644
index 0000000..a0494e6
--- /dev/null
+++ b/src/chatApp/ChatGUI.java
@@ -0,0 +1,167 @@
+
+package chatApp ;
+
+@SuppressWarnings( "javadoc" )
+public class ChatGUI extends javax.swing.JFrame {
+
+ public boolean messageReady = false ;
+ public String message ;
+ public String username ;
+ /*
+ public void giveTitle(String name)
+ {
+ this.username = name ;
+ setTitle("logged in as:" + name ) ;
+ }
+ */
+ public String getMessageOut()
+ {
+ if( this.message.contentEquals( "" ) || this.message.contentEquals( " " ) )
+ {
+ this.messageReady = false ;
+ return null ;
+ }
+ if( this.messageReady )
+ {
+ this.messageReady = false ;
+ return this.message ;
+ }
+ return null ;
+ }
+
+
+ public void printMessage( String messageOut )
+ {
+ messageOut = String.format( "%s\n%s", this.jTextArea1.getText(), messageOut ) ;
+ this.jTextArea1.setText( null ) ;
+ this.jTextArea1.setText( messageOut ) ;
+ jTextArea1.moveCaretPosition( jTextArea1.getDocument().getLength() );
+ }
+
+
+ public ChatGUI() {
+ initComponents();
+ }
+
+
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">
+ private void initComponents() {
+
+ jTextField1 = new javax.swing.JTextField();
+ jButton1 = new javax.swing.JButton();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ jTextArea1 = new javax.swing.JTextArea();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
+ setTitle("logged in as: " + this.username );
+
+ jButton1.setText("send");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ setResizable(false);
+ jTextArea1.setEditable(false);
+ jTextArea1.setColumns(20);
+ jTextArea1.setRows(5);
+ jTextArea1.setWrapStyleWord(true);
+ jTextArea1.setLineWrap( true );
+ jTextArea1.moveCaretPosition( jTextArea1.getDocument().getLength() );
+ jScrollPane2.setViewportView(jTextArea1);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap(50, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(jScrollPane2)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 610, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton1)))
+ .addGap(50, 50, 50))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap(50, Short.MAX_VALUE)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jButton1))
+ .addGap(50, 50, 50))
+ );
+
+ pack();
+ setLocationRelativeTo(null);
+ }// </editor-fold>
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt)
+ {
+ if( this.jTextField1.getText() != null )
+ {
+ this.message = this.jTextField1.getText() ;
+ this.messageReady = true ;
+ this.jTextField1.setText( null ) ;
+ }
+ }
+
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
+
+ if( this.jTextField1.getText() != null )
+ {
+ this.message = this.jTextField1.getText() ;
+ this.messageReady = true ;
+ this.jTextField1.setText( null ) ;
+ }
+
+ }
+
+
+ public static void main(String args[]) {
+
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(ChatGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(ChatGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(ChatGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(ChatGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new ChatGUI().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify
+ private javax.swing.JButton jButton1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JTextArea jTextArea1;
+ private javax.swing.JTextField jTextField1;
+ // End of variables declaration
+}
diff --git a/src/chatApp/ChattingUI$1.class b/src/chatApp/ChattingUI$1.class
new file mode 100644
index 0000000..db63e6b
--- /dev/null
+++ b/src/chatApp/ChattingUI$1.class
Binary files differ
diff --git a/src/chatApp/ChattingUI$2.class b/src/chatApp/ChattingUI$2.class
new file mode 100644
index 0000000..e764ea1
--- /dev/null
+++ b/src/chatApp/ChattingUI$2.class
Binary files differ
diff --git a/src/chatApp/ChattingUI$3.class b/src/chatApp/ChattingUI$3.class
new file mode 100644
index 0000000..a319de8
--- /dev/null
+++ b/src/chatApp/ChattingUI$3.class
Binary files differ
diff --git a/src/chatApp/ChattingUI.class b/src/chatApp/ChattingUI.class
new file mode 100644
index 0000000..770f2e4
--- /dev/null
+++ b/src/chatApp/ChattingUI.class
Binary files differ
diff --git a/src/chatApp/ClientGUI$1.class b/src/chatApp/ClientGUI$1.class
new file mode 100644
index 0000000..081ae66
--- /dev/null
+++ b/src/chatApp/ClientGUI$1.class
Binary files differ
diff --git a/src/chatApp/ClientGUI$2.class b/src/chatApp/ClientGUI$2.class
new file mode 100644
index 0000000..0cf7cc8
--- /dev/null
+++ b/src/chatApp/ClientGUI$2.class
Binary files differ
diff --git a/src/chatApp/ClientGUI.class b/src/chatApp/ClientGUI.class
new file mode 100644
index 0000000..9419057
--- /dev/null
+++ b/src/chatApp/ClientGUI.class
Binary files differ
diff --git a/src/javaChat/ClientGUI.java b/src/chatApp/ClientGUI.java
index 3b98486..cfb7726 100644
--- a/src/javaChat/ClientGUI.java
+++ b/src/chatApp/ClientGUI.java
@@ -1,22 +1,18 @@
-package javaChat;
+package chatApp;
import java.net.* ;
import java.io.* ;
-/**
- *
- *
- * @author osheas1
- * @version 1.0.0 2020-12-07 Initial implementation
- *
- */
-public class ClientGUI
+public class ClientGUI
{
-
+
+ static LoginGUI login = new LoginGUI() ;
+ static ChatGUI chatRoom = new ChatGUI() ;
+
+ @SuppressWarnings( "javadoc" )
public static void main( String[] args ) throws IOException
{
- UserInterface login = new UserInterface() ;
login.setVisible( true );
boolean done = false ;
@@ -34,25 +30,43 @@ public class ClientGUI
// Create communication streams
DataInputStream dataStreamIn = new DataInputStream( socket.getInputStream() ) ;
- DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ;
-
- BufferedReader keyboard = new BufferedReader( new InputStreamReader( System.in ) ) ;
+ DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ;
dataStreamOut.writeUTF( username ) ;
+ chatRoom.setTitle( "logged in as: " + username ) ;
+ chatRoom.setVisible( true ) ;
+
// Thread for sending messages
Thread sendMessage = new Thread(new Runnable()
{
@Override
public void run()
- {
- System.out.print( "\n-= Type /help for a list of commands =-" ) ;
+ {
while( true )
{
try
{
- String messageOut = keyboard.readLine() ;
- dataStreamOut.writeUTF( messageOut ) ;
+ // if-statement is only triggered if client closes window (disconnects)
+ if( !chatRoom.isVisible() )
+ {
+ dataStreamOut.writeUTF( "/quit" ) ;
+ dataStreamIn.close() ;
+ dataStreamOut.close() ;
+ socket.close() ;
+ System.exit( 0 ) ;
+ }
+ // extract message information from GUI text field
+ if( chatRoom.messageReady )
+ {
+ String messageOut = chatRoom.getMessageOut() ;
+ if( messageOut == null )
+ {
+ continue ;
+ }
+ dataStreamOut.writeUTF( messageOut ) ;
+ }
+ System.out.print("") ;
}
catch( IOException x )
{
@@ -73,9 +87,9 @@ public class ClientGUI
while( true )
{
try
- {
- String messageIn = dataStreamIn.readUTF() ;
- System.out.printf( "%n%s\n", messageIn ) ;
+ {
+ String messageIn = dataStreamIn.readUTF() ;
+ chatRoom.printMessage( messageIn ) ;
}
catch( IOException x )
{
@@ -89,9 +103,7 @@ public class ClientGUI
// Begin threads
sendMessage.start() ;
receiveMessage.start() ;
-
-
+
}
-
}
// end class ClientGUI \ No newline at end of file
diff --git a/src/chatApp/LoginGUI$1.class b/src/chatApp/LoginGUI$1.class
new file mode 100644
index 0000000..2a7bd26
--- /dev/null
+++ b/src/chatApp/LoginGUI$1.class
Binary files differ
diff --git a/src/chatApp/LoginGUI$2.class b/src/chatApp/LoginGUI$2.class
new file mode 100644
index 0000000..d2fe6ce
--- /dev/null
+++ b/src/chatApp/LoginGUI$2.class
Binary files differ
diff --git a/src/chatApp/LoginGUI$3.class b/src/chatApp/LoginGUI$3.class
new file mode 100644
index 0000000..1b71f0a
--- /dev/null
+++ b/src/chatApp/LoginGUI$3.class
Binary files differ
diff --git a/src/chatApp/LoginGUI$4.class b/src/chatApp/LoginGUI$4.class
new file mode 100644
index 0000000..7aaabcb
--- /dev/null
+++ b/src/chatApp/LoginGUI$4.class
Binary files differ
diff --git a/src/chatApp/LoginGUI$5.class b/src/chatApp/LoginGUI$5.class
new file mode 100644
index 0000000..56d6eec
--- /dev/null
+++ b/src/chatApp/LoginGUI$5.class
Binary files differ
diff --git a/src/chatApp/LoginGUI$6.class b/src/chatApp/LoginGUI$6.class
new file mode 100644
index 0000000..1102a99
--- /dev/null
+++ b/src/chatApp/LoginGUI$6.class
Binary files differ
diff --git a/src/chatApp/LoginGUI.class b/src/chatApp/LoginGUI.class
new file mode 100644
index 0000000..ae0c7ee
--- /dev/null
+++ b/src/chatApp/LoginGUI.class
Binary files differ
diff --git a/src/chatApp/LoginGUI.java b/src/chatApp/LoginGUI.java
new file mode 100644
index 0000000..f6ad5b8
--- /dev/null
+++ b/src/chatApp/LoginGUI.java
@@ -0,0 +1,182 @@
+package chatApp;
+
+import java.awt.* ;
+import java.util.* ;
+import javax.swing.* ;
+
+public class LoginGUI extends javax.swing.JFrame {
+
+
+ String ip ;
+ String username ;
+ boolean done ;
+
+
+ public String getIP()
+ {
+ return ip ;
+ }
+
+ public String getUsername()
+ {
+ return username ;
+ }
+
+ public boolean isDone()
+ {
+ return done ;
+ }
+
+
+public LoginGUI() {
+ initComponents();
+}
+
+@SuppressWarnings("unchecked")
+// <editor-fold defaultstate="collapsed" desc="Generated Code">
+private void initComponents()
+ {
+
+
+ jLabel1 = new javax.swing.JLabel();
+ jTextField1 = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ ipBox = new javax.swing.JTextField();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("java chat login");
+ setAlwaysOnTop(true);
+ setResizable(false);
+
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel1.setText("Enter Server's IP:");
+
+ jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+ ipBox.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+ jTextField1.setToolTipText("");
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel2.setText("Enter Username:");
+
+ jLabel3.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
+ jLabel3.setText("inputs must be at least one character");
+ jLabel3.setEnabled(false);
+
+ ipBox.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap(43, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
+ .addComponent(ipBox))
+ .addGap(40, 40, 40))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(jLabel3)
+ .addContainerGap())))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(40, 40, 40)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(ipBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel3)
+ .addContainerGap(22, Short.MAX_VALUE))
+ );
+
+ pack();
+ setLocationRelativeTo(null);
+ }// </editor-fold>
+
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt)
+ {
+ if( ipBox.getText().isBlank() )
+ {
+ jLabel3.setEnabled( true );
+ }
+ else
+ {
+ jTextField1.grabFocus();
+ }
+ }
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt)
+ {
+ if( jTextField1.getText().isBlank() || ipBox.getText().isBlank() )
+ {
+ jLabel3.setEnabled( true );
+ }
+ else
+ {
+ this.ip = ipBox.getText() ;
+ this.username = jTextField1.getText() ;
+ this.done = true ;
+ dispose();
+ }
+ }
+/**
+ * @param args the command line arguments
+ */
+public static void main(String args[]) {
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(LoginGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new LoginGUI().setVisible(true);
+ }
+ });
+}
+
+
+
+// Variables declaration - do not modify
+private javax.swing.JLabel jLabel1;
+private javax.swing.JLabel jLabel2;
+private javax.swing.JLabel jLabel3;
+private javax.swing.JTextField jTextField1;
+private javax.swing.JTextField ipBox;
+// End of variables declaration
+}
diff --git a/src/chatApp/loginDEMO$1.class b/src/chatApp/loginDEMO$1.class
new file mode 100644
index 0000000..1dd8a39
--- /dev/null
+++ b/src/chatApp/loginDEMO$1.class
Binary files differ
diff --git a/src/chatApp/loginDEMO$2.class b/src/chatApp/loginDEMO$2.class
new file mode 100644
index 0000000..887c167
--- /dev/null
+++ b/src/chatApp/loginDEMO$2.class
Binary files differ
diff --git a/src/chatApp/loginDEMO.class b/src/chatApp/loginDEMO.class
new file mode 100644
index 0000000..76e8169
--- /dev/null
+++ b/src/chatApp/loginDEMO.class
Binary files differ
diff --git a/src/demonstration/ChatDEMO$1.class b/src/demonstration/ChatDEMO$1.class
new file mode 100644
index 0000000..4acd2b3
--- /dev/null
+++ b/src/demonstration/ChatDEMO$1.class
Binary files differ
diff --git a/src/demonstration/ChatDEMO$2.class b/src/demonstration/ChatDEMO$2.class
new file mode 100644
index 0000000..bd4defe
--- /dev/null
+++ b/src/demonstration/ChatDEMO$2.class
Binary files differ
diff --git a/src/demonstration/ChatDEMO$3.class b/src/demonstration/ChatDEMO$3.class
new file mode 100644
index 0000000..68a31bf
--- /dev/null
+++ b/src/demonstration/ChatDEMO$3.class
Binary files differ
diff --git a/src/demonstration/ChatDEMO.class b/src/demonstration/ChatDEMO.class
new file mode 100644
index 0000000..abe7857
--- /dev/null
+++ b/src/demonstration/ChatDEMO.class
Binary files differ
diff --git a/src/demonstration/ChatDEMO.java b/src/demonstration/ChatDEMO.java
new file mode 100644
index 0000000..8156e62
--- /dev/null
+++ b/src/demonstration/ChatDEMO.java
@@ -0,0 +1,166 @@
+package demonstration;
+
+@SuppressWarnings( "javadoc" )
+public class ChatDEMO extends javax.swing.JFrame {
+
+ public boolean messageReady = false ;
+ public String message ;
+ public String username ;
+ /*
+ public void giveTitle(String name)
+ {
+ this.username = name ;
+ setTitle("logged in as:" + name ) ;
+ }
+ */
+ public String getMessageOut()
+ {
+ if( this.message.contentEquals( "" ) || this.message.contentEquals( " " ) )
+ {
+ this.messageReady = false ;
+ return null ;
+ }
+ if( this.messageReady )
+ {
+ this.messageReady = false ;
+ return this.message ;
+ }
+ return null ;
+ }
+
+
+ public void printMessage( String messageOut )
+ {
+ messageOut = String.format( "%s\n%s", this.jTextArea1.getText(), messageOut ) ;
+ this.jTextArea1.setText( null ) ;
+ this.jTextArea1.setText( messageOut ) ;
+ jTextArea1.moveCaretPosition( jTextArea1.getDocument().getLength() );
+ }
+
+
+ public ChatDEMO() {
+ initComponents();
+ }
+
+
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">
+ private void initComponents() {
+
+ jTextField1 = new javax.swing.JTextField();
+ jButton1 = new javax.swing.JButton();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ jTextArea1 = new javax.swing.JTextArea();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
+ setTitle("logged in as: " + this.username );
+
+ jButton1.setText("send");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ setResizable(false);
+ jTextArea1.setEditable(false);
+ jTextArea1.setColumns(20);
+ jTextArea1.setRows(5);
+ jTextArea1.setWrapStyleWord(true);
+ jTextArea1.setLineWrap( true );
+ jTextArea1.moveCaretPosition( jTextArea1.getDocument().getLength() );
+ jScrollPane2.setViewportView(jTextArea1);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap(50, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(jScrollPane2)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 610, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton1)))
+ .addGap(50, 50, 50))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap(50, Short.MAX_VALUE)
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jButton1))
+ .addGap(50, 50, 50))
+ );
+
+ pack();
+ setLocationRelativeTo(null);
+ }// </editor-fold>
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt)
+ {
+ if( this.jTextField1.getText() != null )
+ {
+ this.message = this.jTextField1.getText() ;
+ this.messageReady = true ;
+ this.jTextField1.setText( null ) ;
+ }
+ }
+
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
+
+ if( this.jTextField1.getText() != null )
+ {
+ this.message = this.jTextField1.getText() ;
+ this.messageReady = true ;
+ this.jTextField1.setText( null ) ;
+ }
+
+ }
+
+
+ public static void main(String args[]) {
+
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(ChatDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(ChatDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(ChatDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(ChatDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new ChatDEMO().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify
+ private javax.swing.JButton jButton1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JTextArea jTextArea1;
+ private javax.swing.JTextField jTextField1;
+ // End of variables declaration
+}
diff --git a/src/demonstration/ClientDEMO$1.class b/src/demonstration/ClientDEMO$1.class
new file mode 100644
index 0000000..85074bf
--- /dev/null
+++ b/src/demonstration/ClientDEMO$1.class
Binary files differ
diff --git a/src/demonstration/ClientDEMO$2.class b/src/demonstration/ClientDEMO$2.class
new file mode 100644
index 0000000..8973685
--- /dev/null
+++ b/src/demonstration/ClientDEMO$2.class
Binary files differ
diff --git a/src/demonstration/ClientDEMO.class b/src/demonstration/ClientDEMO.class
new file mode 100644
index 0000000..4b0c46c
--- /dev/null
+++ b/src/demonstration/ClientDEMO.class
Binary files differ
diff --git a/src/demonstration/ClientDEMO.java b/src/demonstration/ClientDEMO.java
new file mode 100644
index 0000000..dbd91b3
--- /dev/null
+++ b/src/demonstration/ClientDEMO.java
@@ -0,0 +1,110 @@
+package demonstration;
+
+import java.net.* ;
+import java.io.* ;
+
+@SuppressWarnings( "javadoc" )
+public class ClientDEMO
+ {
+
+ static LoginDEMO loginDemo = new LoginDEMO() ;
+ static ChatDEMO chatRoom = new ChatDEMO() ;
+
+ @SuppressWarnings( "javadoc" )
+ public static void main( String[] args ) throws IOException
+ {
+
+ loginDemo.setVisible( true );
+
+ boolean done = false ;
+ while( !done )
+ {
+ done = loginDemo.isDone() ;
+ System.out.print("");
+ }
+
+ String ip = loginDemo.getIP() ;
+ String username = loginDemo.getUsername() ;
+
+ // Open your connection to a server, at port 6789
+ Socket socket = new Socket( ip , 6789 ) ;
+
+ // Create communication streams
+ DataInputStream dataStreamIn = new DataInputStream( socket.getInputStream() ) ;
+ DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ;
+
+ dataStreamOut.writeUTF( username ) ;
+
+ chatRoom.setTitle( "logged in as: " + username ) ;
+ chatRoom.setVisible( true ) ;
+
+ // Thread for sending messages
+ Thread sendMessage = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ while( true )
+ {
+ try
+ {
+ // if-statement is only triggered if client closes window (disconnects)
+ if( !chatRoom.isVisible() )
+ {
+ dataStreamOut.writeUTF( "/quit" ) ;
+ dataStreamIn.close() ;
+ dataStreamOut.close() ;
+ socket.close() ;
+ System.exit( 0 ) ;
+ }
+ // extract message information from GUI text field
+ if( chatRoom.messageReady )
+ {
+ String messageOut = chatRoom.getMessageOut() ;
+ if( messageOut == null )
+ {
+ continue ;
+ }
+ dataStreamOut.writeUTF( messageOut ) ;
+ }
+ System.out.print("") ;
+ }
+ catch( IOException x )
+ {
+ x.printStackTrace() ;
+ System.exit( 0 ) ;
+ }
+ }
+ }
+ }) ;
+
+ // Thread for receiving messages
+ Thread receiveMessage = new Thread( new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ while( true )
+ {
+ try
+ {
+ String messageIn = dataStreamIn.readUTF() ;
+ chatRoom.printMessage( messageIn ) ;
+ }
+ catch( IOException x )
+ {
+ x.printStackTrace() ;
+ System.exit( 0 ) ;
+ }
+ }
+ }
+ });
+
+ // Begin threads
+ sendMessage.start() ;
+ receiveMessage.start() ;
+
+ }
+ }
+ // end class ClientGUI \ No newline at end of file
diff --git a/src/demonstration/LoginDEMO$1.class b/src/demonstration/LoginDEMO$1.class
new file mode 100644
index 0000000..19951a3
--- /dev/null
+++ b/src/demonstration/LoginDEMO$1.class
Binary files differ
diff --git a/src/demonstration/LoginDEMO$2.class b/src/demonstration/LoginDEMO$2.class
new file mode 100644
index 0000000..339afeb
--- /dev/null
+++ b/src/demonstration/LoginDEMO$2.class
Binary files differ
diff --git a/src/demonstration/LoginDEMO.class b/src/demonstration/LoginDEMO.class
new file mode 100644
index 0000000..0acbd60
--- /dev/null
+++ b/src/demonstration/LoginDEMO.class
Binary files differ
diff --git a/src/demonstration/LoginDEMO.java b/src/demonstration/LoginDEMO.java
new file mode 100644
index 0000000..d67f852
--- /dev/null
+++ b/src/demonstration/LoginDEMO.java
@@ -0,0 +1,158 @@
+package demonstration;
+
+@SuppressWarnings( "javadoc" )
+public class LoginDEMO extends javax.swing.JFrame {
+
+ /**
+ * Creates new form loginGUI
+ */
+
+ public String ip ;
+ public String username ;
+ public boolean done ;
+
+ public String getIP()
+ {
+ return this.ip ;
+ }
+
+ public String getUsername()
+ {
+ return this.username ;
+ }
+
+ public boolean isDone()
+ {
+ return this.done ;
+ }
+
+ public LoginDEMO() {
+ initComponents();
+ }
+
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">
+ private void initComponents() {
+
+ jPasswordField1 = new javax.swing.JPasswordField();
+ jLabel1 = new javax.swing.JLabel();
+ jTextField1 = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("java chat login DEMO");
+ setAlwaysOnTop(true);
+ setResizable(false);
+
+ jPasswordField1.setEditable(false);
+ jPasswordField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+ jPasswordField1.setText("12.34.56.78");
+
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel1.setText("Enter Server's IP:");
+
+ jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+ jTextField1.setToolTipText("");
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jLabel2.setText("Enter Username:");
+
+ jLabel3.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
+ jLabel3.setText("username must be at least one character");
+ jLabel3.setEnabled(false);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap(43, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(jTextField1)
+ .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
+ .addGap(40, 40, 40))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(jLabel3)
+ .addContainerGap())))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(40, 40, 40)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel3)
+ .addContainerGap(22, Short.MAX_VALUE))
+ );
+
+ pack();
+ setLocationRelativeTo(null);
+ }// </editor-fold>
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
+ this.ip = "74.69.251.12" ;
+ if( jTextField1.getText().isBlank() )
+ {
+ jLabel3.setEnabled( true );
+ }
+ else
+ {
+ this.username = jTextField1.getText() ;
+ this.done = true ;
+ dispose();
+ }
+ }
+
+ public static void main(String args[]) {
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(LoginDEMO.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new LoginDEMO().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JPasswordField jPasswordField1;
+ private javax.swing.JTextField jTextField1;
+ // End of variables declaration
+}
diff --git a/src/javaChat/ChatServer.java b/src/javaChat/ChatServer.java
deleted file mode 100644
index 22c5575..0000000
--- a/src/javaChat/ChatServer.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package javaChat;
-
-import java.net.* ;
-import java.util.* ;
-import java.io.* ;
-
-public class ChatServer
- {
-
- // List of all active users in Server
- static ArrayList<ClientHandler> userList = new ArrayList<>() ;
-
- /**
- * Accepts Client requests to join chat server, and
- * creates new thread for each individual client.
- *
- * @param args
- * @throws IOException
- */
- public static void main( String[] args ) throws IOException
- {
-
- // Register service on port 6789
- ServerSocket serverSocket = new ServerSocket( 6789 ) ;
- Socket socket = null ;
-
- System.out.println( "\nServer established. Awaiting connections..." ) ;
-
- // Accept client requests
- while( true )
- {
- socket = serverSocket.accept() ;
-
- DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ;
- DataInputStream dataStreamIn = new DataInputStream ( socket.getInputStream() ) ;
-
- System.out.println( "\nClient connection detected, requesting username..." ) ;
- String username = dataStreamIn.readUTF() ;
-
- ClientHandler handle = new ClientHandler( socket, username, dataStreamOut, dataStreamIn ) ;
-
- System.out.println( "\nCreating new thread...\n" ) ;
- Thread thread = new Thread( handle ) ;
-
- userList.add( handle ) ;
-
- thread.start() ;
-
- }
- }
-
- }
- // end class ChatClient
-
-
-
-
- // This class manages the actual messages being sent around
- @SuppressWarnings( "javadoc" )
- class ClientHandler implements Runnable
- {
-
- Socket socket ;
- String username ;
- final DataOutputStream dataStreamOut ;
- final DataInputStream dataStreamIn ;
- boolean loggedIn ;
- private ArrayList<ClientHandler> userList ;
-
-
- /**
- * Constructor
- * @param s : client socket
- * @param user : client's user-name
- * @param dos : data stream to client
- * @param dis : data stream from client
- */
- public ClientHandler( Socket s, String user,
- DataOutputStream dos,
- DataInputStream dis )
- {
- this.username = user ;
- this.socket = s ;
- this.dataStreamOut = dos ;
- this.dataStreamIn = dis ;
- this.loggedIn = true ;
-
- }
-
- @Override
- public void run()
- {
-
- // Note the connection of the new user
- String announcement = String.format( "-= User \"%s\" has successfully connected =-\n", this.username ) ;
- System.out.println( announcement ) ;
-
- // Distribute announcement to entire server
- distributeAll( announcement ) ;
-
- // Message management
- String message = "" ;
- while( true )
- {
- // Read incoming messages
- try
- {
- message = this.dataStreamIn.readUTF() ;
- }
- catch ( IOException x )
- {
- x.printStackTrace() ;
- }
-
- // Check message for user commands, returns TRUE is user quits
- if( commands(message, this) )
- {
- break ;
- }
-
- // Print the message server-side
- message = String.format( "%s: %s", this.username, message ) ;
- System.out.println( message ) ;
-
- // Distribute the message to all users
- sendMessage( message ) ;
- // end try
-
- }
-
- try
- {
- this.loggedIn = false ;
- this.socket.close() ;
- }
- catch( IOException x )
- {
- x.printStackTrace() ;
- }
- }
-
-
- // This method manages the usage of user-commands
- public boolean commands(String message, ClientHandler user)
- {
- String[] commands = new String[] {"/help", "/quit", "/userlist"} ;
-
- try {
-
- // Quit command terminates connection, with an announcement
- if( message.equals( "/quit" ))
- {
- String announcement = String.format( "\n-= \"%s\" has disconnected =- \n", user.username ) ;
- System.out.println( announcement ) ;
- distributeAll( announcement ) ;
- return true ;
- }
-
- if( message.equals( "/userlist" ) )
- {
- user.dataStreamOut.writeUTF( "Current list of users in the server: " ) ;
- for( ClientHandler users : ChatServer.userList )
- {
- if( !users.loggedIn )
- {
- continue ;
- }
-
- user.dataStreamOut.writeUTF( users.username ) ;
-
- }
- }
-
- if( message.contentEquals( "/help" ) )
- {
- user.dataStreamOut.writeUTF( "\nAll available commands: " );
- for(int i = 0; i < commands.length; i++ )
- {
- user.dataStreamOut.writeUTF( commands[i] );
- }
-
- user.dataStreamOut.writeUTF( "\n" ) ;
- }
- }
-
- catch( IOException x )
- {
- System.out.println( x ) ;
- }
-
- return false ;
- }
-
-
- // Convenience method to send messages (but not to the user that's sending the message)
- private void sendMessage(String message)
- {
- try
- {
- for( ClientHandler users : ChatServer.userList )
- {
- if( !users.loggedIn || users.equals( this ) )
- {
- continue ;
- }
- users.dataStreamOut.writeUTF( "> " + message ) ;
- }
- }
- catch ( IOException x )
- {
- x.printStackTrace() ;
- }
- }
-
-
- // Convenience method to distribute messages to all clients (announcements)
- private void distributeAll(String message)
- {
- try
- {
- for( ClientHandler users : ChatServer.userList )
- {
- if( !users.loggedIn )
- {
- continue ;
- }
- users.dataStreamOut.writeUTF( message ) ;
- }
- }
- catch ( IOException x )
- {
- x.printStackTrace() ;
- }
- }
-
- }
- // end class ClientHandler \ No newline at end of file
diff --git a/src/javaChat/UserInterface.java b/src/javaChat/UserInterface.java
deleted file mode 100644
index 1d8f906..0000000
--- a/src/javaChat/UserInterface.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package javaChat;
-
-import java.awt.* ;
-import java.util.* ;
-import javax.swing.* ;
-
-public class UserInterface extends javax.swing.JFrame {
-
-
- String ip ;
- String username ;
- boolean done ;
-
-/**
- * Creates new form loginFrame
- */
-public UserInterface() {
- initComponents();
-}
-
-/**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
-@SuppressWarnings("unchecked")
-// <editor-fold defaultstate="collapsed" desc="Generated Code">
-private void initComponents()
- {
-
- jTextField1 = new javax.swing.JTextField();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jTextField2 = new javax.swing.JTextField();
- jButton1 = new javax.swing.JButton();
- jSlider1 = new javax.swing.JSlider();
- jSlider2 = new javax.swing.JSlider();
- jSlider3 = new javax.swing.JSlider();
- jSlider4 = new javax.swing.JSlider();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("Java Chat");
- setAlwaysOnTop(true);
- setBackground(new java.awt.Color(255, 255, 255));
- setForeground(java.awt.Color.white);
- setResizable(false);
-
- jTextField1.setEditable(false);
- jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
- jTextField1.setText("0.0.0.0");
-
- jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jLabel1.setText("Enter Server's I.P. Address:");
-
- jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- jLabel2.setText("Enter your desired username:");
-
- jTextField2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
- jTextField2.setActionCommand("<Not Set>");
-
- jButton1.setText("Connect");
- jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- jButton1.setOpaque(false);
- jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- jButton1MouseClicked(evt);
- }
- });
-
- jSlider1.setMaximum(999);
- jSlider1.setOrientation(javax.swing.JSlider.VERTICAL);
- jSlider1.setValue(0);
- jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- jSlider1StateChanged(evt);
- }
- });
-
- jSlider2.setMaximum(999);
- jSlider2.setOrientation(javax.swing.JSlider.VERTICAL);
- jSlider2.setValue(0);
- jSlider2.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- jSlider2StateChanged(evt);
- }
- });
-
- jSlider3.setMaximum(999);
- jSlider3.setOrientation(javax.swing.JSlider.VERTICAL);
- jSlider3.setValue(0);
- jSlider3.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- jSlider3StateChanged(evt);
- }
- });
-
- jSlider4.setMaximum(999);
- jSlider4.setOrientation(javax.swing.JSlider.VERTICAL);
- jSlider4.setValue(0);
- jSlider4.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- jSlider4StateChanged(evt);
- }
- });
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(60, 60, 60)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(18, 18, 18)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGroup(layout.createSequentialGroup()
- .addGap(162, 162, 162)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
- .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jSlider2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jSlider3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jSlider4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(56, 56, 56))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jSlider3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
- .addComponent(jSlider2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
- .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jSlider4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(40, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel1))
- .addGap(36, 36, 36)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2))
- .addGap(28, 28, 28)
- .addComponent(jButton1)
- .addGap(30, 30, 30))))
- );
-
- pack();
- }// </editor-fold>
-
-private void jButton1MouseClicked(java.awt.event.MouseEvent evt)
- {
- ip = jTextField1.getText() ;
- username = jTextField2.getText() ;
- //System.out.printf( "IP: %s \nUsername: %s\n", ip, username ) ;
-
-
- done = true ;
- setVisible( false ) ;
- dispose() ;
-
- }
-
-private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt)
- {
- Integer a = jSlider1.getValue() ;
- Integer b = jSlider2.getValue() ;
- Integer c = jSlider3.getValue() ;
- Integer d = jSlider4.getValue() ;
-
- String ip = String.format("%s.%s.%s.%s", a, b, c, d) ;
-
- jTextField1.setText( ip.toString() ) ;
- }
-
-private void jSlider2StateChanged(javax.swing.event.ChangeEvent evt)
- {
- Integer a = jSlider1.getValue() ;
- Integer b = jSlider2.getValue() ;
- Integer c = jSlider3.getValue() ;
- Integer d = jSlider4.getValue() ;
-
- String ip = String.format("%s.%s.%s.%s", a, b, c, d) ;
-
- jTextField1.setText( ip.toString() ) ;
- }
-
-private void jSlider3StateChanged(javax.swing.event.ChangeEvent evt)
- {
- Integer a = jSlider1.getValue() ;
- Integer b = jSlider2.getValue() ;
- Integer c = jSlider3.getValue() ;
- Integer d = jSlider4.getValue() ;
-
- String ip = String.format("%s.%s.%s.%s", a, b, c, d) ;
-
- jTextField1.setText( ip.toString() ) ;
- }
-
-private void jSlider4StateChanged(javax.swing.event.ChangeEvent evt)
- {
- Integer a = jSlider1.getValue() ;
- Integer b = jSlider2.getValue() ;
- Integer c = jSlider3.getValue() ;
- Integer d = jSlider4.getValue() ;
-
- String ip = String.format("%s.%s.%s.%s", a, b, c, d) ;
-
- jTextField1.setText( ip.toString() ) ;
- }
-
-/**
- * @param args the command line arguments
- */
-public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(UserInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(UserInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(UserInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(UserInterface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
-
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new UserInterface().setVisible(true);
- }
- });
-}
-
-
-public String getIP()
- {
- return ip ;
- }
-
-public String getUsername()
- {
- return username ;
- }
-
-public boolean isDone()
- {
- return done ;
- }
-
-// Variables declaration - do not modify
-private javax.swing.JButton jButton1;
-private javax.swing.JLabel jLabel1;
-private javax.swing.JLabel jLabel2;
-private javax.swing.JSlider jSlider1;
-private javax.swing.JSlider jSlider2;
-private javax.swing.JSlider jSlider3;
-private javax.swing.JSlider jSlider4;
-private javax.swing.JTextField jTextField1;
-private javax.swing.JTextField jTextField2;
-// End of variables declaration
-}