The document describes a program for a multi-client chat client-server application using Java graphical programming. It includes the code for the ChatServer class that handles connections from multiple clients and broadcasts messages. It also includes the code for the ChatClient class that allows a client to connect to the server, send and receive messages, and view an online users list. The program allows for real-time text communication between multiple clients connected to a central server.
JavaFX 8 est disponible depuis mars 2014 et apporte son lot de nouveautés. Gradle est en version 2 depuis juillet 2014. Deux technologies plus que prometteuses: JavaFX donne un coup de jeune au développement d’applications desktop en Java en apportant un navigateur web intégré, le support des WebSockets, de la 3D, et bien d’autres. Gradle est l’outil de d’automatisation de build à la mode, apportant de superbes possibilités par rapport rapport à maven, outil vieillissant, grâce à l’engouement de la communauté vis à vis de cet outil mais aussi par le fait de la technologie utilisée en son sein: groovy. Venez découvrir comment il est possible de réaliser rapidement une application à la mode en JavaFX avec un outil à la mode également. Bref venez à une session trendy.
REX about JavaFX8 used in SlideshowFX. This presentation covers concept from JavaFX as well as technologies like OSGi, Vert.x, LeapMotion, nashorn and friends in order to make them communicate inside one application developed in JavaFX.
This presentation was made at the ElsassJUG
JavaFX 8 est disponible depuis mars 2014 et apporte son lot de nouveautés. Gradle est en version 2 depuis juillet 2014. Deux technologies plus que prometteuses: JavaFX donne un coup de jeune au développement d’applications desktop en Java en apportant un navigateur web intégré, le support des WebSockets, de la 3D, et bien d’autres. Gradle est l’outil de d’automatisation de build à la mode, apportant de superbes possibilités par rapport rapport à maven, outil vieillissant, grâce à l’engouement de la communauté vis à vis de cet outil mais aussi par le fait de la technologie utilisée en son sein: groovy. Venez découvrir comment il est possible de réaliser rapidement une application à la mode en JavaFX avec un outil à la mode également. Bref venez à une session trendy.
REX about JavaFX8 used in SlideshowFX. This presentation covers concept from JavaFX as well as technologies like OSGi, Vert.x, LeapMotion, nashorn and friends in order to make them communicate inside one application developed in JavaFX.
This presentation was made at the ElsassJUG
Poche chiacchiere e tanto codice per cercare rendere la nostra vita di
sviluppatori più divertente.
Parleremo di JAX-RS, le annotazioni, l'MVC che mette a disposizione e
l'integrazione di Jersey con Guice.
Useremo AOP per gestire log, transazioni e con l'aiuto di Infinispan
limiteremo le chamate concorrenti sul nostro cluster.
Le temps est révolu où Java EE ne serait qu’à développer des applications de mise à jour de données, avec JSF / EJB / JPA. Aujourd’hui Java EE s’est assoupli et s’est ouvert sur le monde, avec CDI comme clé de voûte et a repoussé nos limites grâce à des capacités d’extension puissantes et faciles d’utilisation comme JCA.
Dans un premier temps, nous reviendrons rapidement sur la place de CDI dans JavaEE 7 et sur ses mécanismes d’extension. Dans un deuxième temps, nous verrons les techniques de connecteurs JCA et comment ils peuvent aussi constituer une possibilité d’ouverture simple à mettre en œuvre. JCA fournit des techniques pour gérer des connexions sortantes ou entrantes, sur des formats ou protocoles variés.
Czym się różnie JMS od AMQP? Co to jest queue? Co to jest topic? Jak zlecać zadania w przyszłości używając kolejek? Jak się do tego podpiąć z Javy? Na te i inne pytania postaram się odpowiedzieć na mojej prezentacji.
INTRODUCTION
In the past we managed to analyse all well knows malwares and theirs C&C servers. We saw a “Kins” malware with unique “ATS” engine acting like real electronic web banking application in auto pilot mode (1). We all know how easy is to go underground and to buy a malware kits with MitB (2) add-ons for well-known electronic banking web applications and also to order a custom one. These injectors are main weapon used from bad guys for the electronic banking application where 2-factor authentication “Tokens” is implemented.
This presentation describes progress on ProcessOne new product, OneTeam Media Server. This is a Flash Media Server used to write interactive, collaborative and real time Flash applications.
Poche chiacchiere e tanto codice per cercare rendere la nostra vita di
sviluppatori più divertente.
Parleremo di JAX-RS, le annotazioni, l'MVC che mette a disposizione e
l'integrazione di Jersey con Guice.
Useremo AOP per gestire log, transazioni e con l'aiuto di Infinispan
limiteremo le chamate concorrenti sul nostro cluster.
Le temps est révolu où Java EE ne serait qu’à développer des applications de mise à jour de données, avec JSF / EJB / JPA. Aujourd’hui Java EE s’est assoupli et s’est ouvert sur le monde, avec CDI comme clé de voûte et a repoussé nos limites grâce à des capacités d’extension puissantes et faciles d’utilisation comme JCA.
Dans un premier temps, nous reviendrons rapidement sur la place de CDI dans JavaEE 7 et sur ses mécanismes d’extension. Dans un deuxième temps, nous verrons les techniques de connecteurs JCA et comment ils peuvent aussi constituer une possibilité d’ouverture simple à mettre en œuvre. JCA fournit des techniques pour gérer des connexions sortantes ou entrantes, sur des formats ou protocoles variés.
Czym się różnie JMS od AMQP? Co to jest queue? Co to jest topic? Jak zlecać zadania w przyszłości używając kolejek? Jak się do tego podpiąć z Javy? Na te i inne pytania postaram się odpowiedzieć na mojej prezentacji.
INTRODUCTION
In the past we managed to analyse all well knows malwares and theirs C&C servers. We saw a “Kins” malware with unique “ATS” engine acting like real electronic web banking application in auto pilot mode (1). We all know how easy is to go underground and to buy a malware kits with MitB (2) add-ons for well-known electronic banking web applications and also to order a custom one. These injectors are main weapon used from bad guys for the electronic banking application where 2-factor authentication “Tokens” is implemented.
This presentation describes progress on ProcessOne new product, OneTeam Media Server. This is a Flash Media Server used to write interactive, collaborative and real time Flash applications.
Hi, I need some one to help me with Design a client-server Chat so.pdffashiongallery1
Given the statement:
For every integer n > 2, n^2 – 6n + 1 > 0.
Is the text below a correct proof of the statement? (YES or NO? Explains your choice.)
Proof: By induction
Let S[n] be the statement that n^2 – 6n + 1 > 0
We show that if S[k] is true for some integer k > 2 then S[k + 1] is also true.
Suppose that k^2 – 6k + 1 > 0 (Induction Hypothesis)
Then (k + 1)^2 – 6(k + 1) + 1 = k^2 + 2k + 1 – 6k – 6 + 1 = (k^2 – 6k + 1) + (2k – 5)
Both bracketed expressions are positive: the first by the Induction Hypothesis, and the second
because k > 2. So S[k + 1] is true.
By PMI, S[n] is true for all n > 2.
Solution
There is nothing wrong in your proof.
BUT given statement is for every integer n > 2, n^2 - 6n +1 > 0
This is False.
Reason: for n = 3
3^2 - 6*3 + 1 = -8
-8 is not greater than zero.
So Given statement is wrong.
It would have been true if the statement is
for every integer n > 5, n^2 - 6n + 1 > 0
Let me know in the comments, if you have any doubt..
Distributed systems
1.Write a program for implementing Client Server communication model.
2.Write a program to show the object communication using RMI.
3.Show the implementation of Remote Procedure Call.
4.Show the implementation of web services.
5.Write a program to execute any one mutual exclusion algorithm.
6.Write a program to implement any one election algorithm
7.Show the implementation of any one clock synchronization algorithm.
8.Write a program to implement two phase commit protocol
- Practical exercises on the use of the threads with TCP
- References
YouTube link :
https://www.youtube.com/playlist?list=PLtDIUAtyP4lhV7CsYfLuIx26UeG4J-ujZ
GitHub :
https://github.com/Ghadeerof
I need you to modify and change the loop in this code without changing.docxhendriciraida
I need you to modify and change the loop in this code without changing the output
import java.io.*;
import java.net.*;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class TCPServer {
/**
* args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int port = 5555;
try (ServerSocket serverSocket = new ServerSocket(port)) {
System.out.println("Server is listening on port " + port);
while (true) {
System.out.println("waiting for a client to connect.");
Socket socket = serverSocket.accept();
System.out.println("New client connected");
DataInputStream dis = new DataInputStream(socket.getInputStream());
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
int option;
String text;
do {
System.out.println("Waiting for mode.");
option=dis.readInt();
switch(option)
{
case 1:
System.out.println("open mode activated.");
dos.writeUTF("open mode activated.");
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
dos.writeUTF(text);
}while(!text.equals("exit"));
break;
case 2:
System.out.println("secure mode activated.");
dos.writeUTF("secure mode activated.");
String keyString="1234567890123456";
String ivString="6543210987654321";
IvParameterSpec iv=new IvParameterSpec(ivString.getBytes("UTF-8"));
SecretKeySpec key=new SecretKeySpec(keyString.getBytes("UTF-8"),"AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, key, iv);
String plainString="";
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(text));
plainString=new String(plainText);
System.out.println("plain text is: " + plainString);
dos.writeUTF(text);
}while(!plainString.equals("exit"));
break;
case 3:
socket.close();
System.out.println("client has disconnected");
break;
}
} while (option !=3);
}
} catch (Exception ex) {
System.out.println("Server exception: " + ex.getMessage());
ex.printStackTrace();
}
}
}
.
I need an explaining for each step in this code and the reason of it-.docxhendriciraida
I need an explaining for each step in this code and the reason of it.
import java.io.*;
import java.net.*;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class TCPServer {
/**
* args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int port = 6000;
try (ServerSocket serverSocket = new ServerSocket(port)) {
System.out.println("Server is listening on port " + port);
while (true) {
System.out.println("waiting for a client to connect.");
Socket socket = serverSocket.accept();
System.out.println("New client connected");
DataInputStream dis = new DataInputStream(socket.getInputStream());
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
int option;
String text;
System.out.println("Waiting for mode.");
option=dis.readInt();
switch(option)
{
case 1:
System.out.println("open mode activated.");
dos.writeUTF("open mode activated.");
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
dos.writeUTF(text);
}while(!text.equals("exit"));
break;
case 2:
System.out.println("secure mode activated.");
dos.writeUTF("secure mode activated.");
String keyString="1234567890123456";
String ivString="6543210987654321";
IvParameterSpec iv=new IvParameterSpec(ivString.getBytes("UTF-8"));
SecretKeySpec key=new SecretKeySpec(keyString.getBytes("UTF-8"),"AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, key, iv);
String plainString="";
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(text));
plainString=new String(plainText);
System.out.println("plain text is: " + plainString);
dos.writeUTF(text);
}while(!plainString.equals("exit"));
break;
case 3:
socket.close();
System.out.println("client has disconnected");
break;
}
}
} catch (Exception ex) {
/*System.out.println("Server exception: " + ex.getMessage());
ex.printStackTrace();
*/
System.out.println("port : " + port);
}
}
}
.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSveerababupersonal22
It consists of cw radar and fmcw radar ,range measurement,if amplifier and fmcw altimeterThe CW radar operates using continuous wave transmission, while the FMCW radar employs frequency-modulated continuous wave technology. Range measurement is a crucial aspect of radar systems, providing information about the distance to a target. The IF amplifier plays a key role in signal processing, amplifying intermediate frequency signals for further analysis. The FMCW altimeter utilizes frequency-modulated continuous wave technology to accurately measure altitude above a reference point.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
1. TUGAS
Membuat Program MultiClient Chatting Client-Server
Menggunakan Bahasa Pemrograman Java Berbasis Grafis
Oleh :
M. Ichsan Barokah
061130701305
6CD
JURUSAN TEKNIK KOMPUTER
POLITEKNIK NEGERI SRIWIJAYA
PALEMBANG
2. Chatting memungkinkan kita untuk selalu bisa berkomunikasi
walaupun kita tidak berada bersamanya di suatu tempat. Aplikasi chatting
merupakan suatu aplikasi yang memungkinkan pengguna (client)
berkomunikasi teks secara langsung (Real Time) dengan pengguna lain dengan
menggunakan media yang ada.
Hal yang harus dilakukan kita terlebih dahulu untuk menjalankan program
chatting ialah melakukan setting alamat IP pada masing-masing client.
Setelah melakukan konfigurasi IP pada masing-masingikomputer
kemudian kita juga harus memastikan bahwa firewall pada masing-masing
komputer harus diaktifkan karena pada beberapa kasus program ini tidak dapat saling
terkoneksi akibat firewall yang aktif pada sistem operasinya.
Berikut adalah listing program MultiClient Chatting Client-Server berbasis
grafis
ChatServer.java
import java.io.*;
import java.net.*;
import java.util.*;
public class ChatServer {
private static int uniqueId;
private ArrayList<ChatServer.ClientThread> clients;
private int port;
private boolean keepGoing;
public ChatServer() {
this.port = 9999;
clients = new ArrayList();
}
3. public void start() {
keepGoing = true;
try {
ServerSocket serverSocket = new ServerSocket(port);
while (keepGoing) {
System.out.println("ChatServer waiting for Clients
on port " + port + ".");
Socket socket = serverSocket.accept();
if (!keepGoing) {
break;
}
ChatServer.ClientThread t = new
ChatServer.ClientThread(socket);
clients.add(t);
t.start();
send("login~" + t.username + "~" + t.username + "
sedang login...~Server~n");
}
try {
serverSocket.close();
for (int i = 0; i < clients.size(); ++i) {
ChatServer.ClientThread tc = clients.get(i);
try {
tc.sInput.close();
tc.sOutput.close();
tc.socket.close();
} catch (IOException ioE) {
}
}
4. } catch (Exception e) {
System.out.println("Exception closing the server
and clients: " + e);
}
} catch (IOException e) {
String msg = "Exception on new ServerSocket: " + e +
"n";
System.out.println(msg);
}
}
private synchronized void send(String message) {
for (int i = clients.size(); --i >= 0;) {
ChatServer.ClientThread ct = clients.get(i);
if (!ct.writeMsg(message)) {
clients.remove(i);
System.out.println("Disconnected Client " +
ct.username + " removed from list.");
}
}
}
private String getClients() {
String s = "";
for (ClientThread clientThread : clients) {
s += clientThread.username + ":";
}
s += "---";
System.out.println(s);
5. return s;
}
private synchronized void remove(int id) {
for (int i = 0; i < clients.size(); ++i) {
ChatServer.ClientThread ct = clients.get(i);
if (ct.id == id) {
clients.remove(i);
return;
}
}
}
public static void main(String[] args) {
ChatServer server = new ChatServer();
server.start();
}
private class ClientThread extends Thread {
private Socket socket;
private ObjectInputStream sInput;
private ObjectOutputStream sOutput;
private int id;
private String username;
public ClientThread(Socket socket) {
id = ++uniqueId;
13. } catch (Exception e) {
}
try {
if (socket != null) {
socket.close();
}
} catch (Exception e) {
}
}
/**
* 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() {
jScrollPane1 = new javax.swing.JScrollPane();
viewTextArea = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
clientTable = new javax.swing.JTable();
postTextField = new javax.swing.JTextField();
kirimButton = new javax.swing.JButton();
lbljpg = new javax.swing.JLabel(new
ImageIcon("E:/rara.jpg"));
14. jLabel2 = new javax.swing.JLabel();
serverTextField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
portTextField = new javax.swing.JTextField();
masukButton = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
usernameTextField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE
);
viewTextArea.setEditable(false);
viewTextArea.setColumns(20);
viewTextArea.setLineWrap(true);
viewTextArea.setRows(5);
viewTextArea.setFocusable(false);
jScrollPane1.setViewportView(viewTextArea);
jScrollPane2.setViewportView(clientTable);
postTextField.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
postTextFieldActionPerformed(evt);
}
});
kirimButton.setText("Kirim");
20. Logger.getLogger(ChatClient.class.getName()).log(Level.SEVERE,
null, ex);
}
}
private void
postTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
kirimButtonActionPerformed(evt);
}
/**
* @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/pla
f.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
21. }
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ChatClient.class.getName()).log
(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ChatClient.class.getName()).log
(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ChatClient.class.getName()).log
(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ChatClient.class.getName()).log
(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new ChatClient().setVisible(true);
}
});
}
// Variables declaration - do not modify
23. switch (type) {
case "recieveText":
res = pengirim + ": " + text;
viewTextArea.setText(viewTextArea.getText() + res + "n");
break;
case "recievePrivateText":
res = pengirim + ": " + text;
if (kepada.equals(username)) {
viewTextArea.setText(viewTextArea.getText() + res + "n");
}
break;
case "login":
viewTextArea.setText(viewTextArea.getText() + pengirim + " sudah
login..." + "n");
clients.add(pengirim);
break;
case "logout":
viewTextArea.setText(viewTextArea.getText() + pengirim + " telah
logout..." + "n");
clients.remove(pengirim);
break;
case "list":
setTable(text);
break;
}
} catch (IOException e) {
24. System.out.println("Server has close the
connection: " + e);
break;
} catch (ClassNotFoundException e2) {
}
}
}
private void setTable(String text) {
int rows = text.split(":").length - 1;
Object[][] data = new Object[rows][1];
for (int i = 0; i < rows; i++) {
String t = text.split(":")[i];
data[i][0] = t;
}
String[] header = {"Clients"};
clientTable.setModel(new DefaultTableModel(data,
header));
}
}
}
Jika dijalankan maka tampilan akan seperti berikut: