Skip to content

Commit 98b78c0

Browse files
committed
optimized
1 parent bf5c273 commit 98b78c0

File tree

6 files changed

+140
-447
lines changed

6 files changed

+140
-447
lines changed

File_Sharing/Client_Main.java

+15-45
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
/*
32
* To change this license header, choose License Headers in Project Properties.
43
* To change this template file, choose Tools | Templates
@@ -7,10 +6,6 @@
76
package file_sharing;
87
import java.awt.event.WindowAdapter;
98
import java.awt.event.WindowEvent;
10-
=======
11-
package file_sharing;
12-
13-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
149
import java.io.DataInputStream;
1510
import java.io.DataOutputStream;
1611
import java.io.File;
@@ -27,7 +22,6 @@
2722
import javax.swing.JFileChooser;
2823

2924
import javax.swing.JFileChooser;
30-
<<<<<<< HEAD
3125
import javax.swing.JFrame;
3226
import javax.swing.JOptionPane;
3327

@@ -41,19 +35,16 @@
4135
class Client {
4236

4337

44-
=======
45-
class Client{
46-
47-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
4838
}
49-
5039
public class Client_Main extends javax.swing.JFrame {
5140

52-
public Socket socket = null;
53-
private DataInputStream input = null;
41+
public Socket socket = null;
42+
private DataInputStream input = null;
5443
private DataOutputStream out = null;
55-
public void setupconnection(String ip,int port){
56-
try
44+
public void setupconnection(String ip,int port) {
45+
46+
47+
try
5748
{
5849
this.socket = new Socket(ip, port);
5950
System.out.println("Connection Established!");
@@ -67,31 +58,25 @@ public void setupconnection(String ip,int port){
6758
{
6859
System.out.println(i);
6960
}
70-
<<<<<<< HEAD
7161
}
7262

7363

74-
=======
75-
}
76-
77-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
7864
/**
7965
* Creates new form Client_Main
8066
*/
8167
public Client_Main() {
8268
initComponents();
8369
}
84-
<<<<<<< HEAD
8570

8671
/**
8772
* This method is called from within the constructor to initialize the form.
8873
* WARNING: Do NOT modify this code. The content of this method is always
8974
* regenerated by the Form Editor.
9075
*/
91-
=======
92-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
9376
@SuppressWarnings("unchecked")
77+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
9478
private void initComponents() {
79+
9580
ipaddress = new javax.swing.JTextField();
9681
port_no = new javax.swing.JTextField();
9782
connect = new javax.swing.JButton();
@@ -176,25 +161,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
176161
);
177162

178163
pack();
179-
}
164+
}// </editor-fold>//GEN-END:initComponents
180165

181-
<<<<<<< HEAD
182166
private void connectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectActionPerformed
183167
// TODO add your handling code here:
184168

185-
=======
186-
private void connectActionPerformed(java.awt.event.ActionEvent evt) throws IOException {
187-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
188169
ip = this.ipaddress.getText();
189170
pn = Integer.parseInt(this.port_no.getText());
190171
user = this.username.getText();
191172
this.setupconnection(ip, pn);
192-
<<<<<<< HEAD
193-
=======
194-
Logger logger = Logger.getLogger("mylog");
195-
196-
FileHandler fileHandler = new FileHandler("E:\\file_sharing\\File_Sharing\\Filapplogg.log", true);
197-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
198173

199174
if(this.socket!=null && user!=null){
200175

@@ -225,20 +200,20 @@ public void windowClosing(WindowEvent evt) {
225200
}
226201

227202

228-
}
203+
}//GEN-LAST:event_connectActionPerformed
229204

230205
private void port_noActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_port_noActionPerformed
231206
// TODO add your handling code here:
232-
}
207+
}//GEN-LAST:event_port_noActionPerformed
208+
233209
private void usernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameActionPerformed
234210
// TODO add your handling code here:
235-
}
211+
}//GEN-LAST:event_usernameActionPerformed
236212

237213
private void ipaddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ipaddressActionPerformed
238214
// TODO add your handling code here:
239-
}
215+
}//GEN-LAST:event_ipaddressActionPerformed
240216

241-
<<<<<<< HEAD
242217
/**
243218
* @param args the command line arguments
244219
*/
@@ -248,9 +223,6 @@ public static void main(String args[]) {
248223
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
249224
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
250225
*/
251-
=======
252-
public static void main(String args[]) {
253-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
254226
try {
255227
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
256228
if ("Nimbus".equals(info.getName())) {
@@ -279,15 +251,13 @@ public void run() {
279251
private String ip;
280252
private int pn;
281253
private String user;
282-
<<<<<<< HEAD
283254
// Variables declaration - do not modify//GEN-BEGIN:variables
284-
=======
285-
>>>>>>> 0f9d468f3e4b42a1a7e306420f7e5335f9eee4ea
286255
private javax.swing.JButton connect;
287256
private javax.swing.JTextField ipaddress;
288257
private javax.swing.JLabel jLabel1;
289258
private javax.swing.JLabel jLabel2;
290259
private javax.swing.JLabel jLabel3;
291260
private javax.swing.JTextField port_no;
292261
private javax.swing.JTextField username;
262+
// End of variables declaration//GEN-END:variables
293263
}

File_Sharing/Progressionbar.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
16
package file_sharing;
27

38
import java.awt.BasicStroke;
@@ -12,13 +17,22 @@
1217
import java.util.Random;
1318
import javax.swing.JPanel;
1419

20+
/**
21+
*
22+
* @author rockstar
23+
*/
1524
public class Progressionbar extends JPanel {
25+
26+
/**
27+
* @param args the command line arguments
28+
*/
1629

1730
float progress = 0;
1831

1932
@Override protected void paintComponent (Graphics g) {
2033
AffineTransform at = new AffineTransform();
2134
super.paintComponent(g);
35+
2236
Graphics2D g2 = (Graphics2D) g;
2337
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
2438
AffineTransform save_ctx = g2.getTransform();

File_Sharing/Server_Main.java

+43-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
16
package file_sharing;
27

38
import java.io.DataInputStream;
@@ -13,9 +18,19 @@
1318
import java.util.logging.Level;
1419
import java.util.logging.Logger;
1520

21+
/**
22+
*
23+
* @author rockstar
24+
*/
25+
26+
27+
1628

1729
public class Server_Main extends javax.swing.JFrame {
1830

31+
/**
32+
* Creates new form Server_Main
33+
*/
1934
public Socket socket = null;
2035
public ServerSocket server = null;
2136
public DataInputStream in = null;
@@ -43,7 +58,13 @@ public Server_Main() {
4358
initComponents();
4459
}
4560

61+
/**
62+
* This method is called from within the constructor to initialize the form.
63+
* WARNING: Do NOT modify this code. The content of this method is always
64+
* regenerated by the Form Editor.
65+
*/
4666
@SuppressWarnings("unchecked")
67+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
4768
private void initComponents() {
4869

4970
portno = new javax.swing.JTextField();
@@ -96,12 +117,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
96117
);
97118

98119
pack();
99-
}
100-
private void portnoActionPerformed(java.awt.event.ActionEvent evt) {
120+
}// </editor-fold>//GEN-END:initComponents
101121

102-
}
122+
private void portnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_portnoActionPerformed
123+
// TODO add your handling code here:
124+
}//GEN-LAST:event_portnoActionPerformed
103125

104-
private void start_serverActionPerformed(java.awt.event.ActionEvent evt) {
126+
private void start_serverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_start_serverActionPerformed
127+
// TODO add your handling code here:
105128
pn = Integer.parseInt(this.portno.getText());
106129

107130
this.setupconnection(pn);
@@ -118,16 +141,25 @@ public void run(){
118141
}
119142
});
120143
t1.start();
121-
144+
//
122145

123146

124147

125148
}
126149

127150

128151

129-
}
152+
}//GEN-LAST:event_start_serverActionPerformed
153+
154+
/**
155+
* @param args the command line arguments
156+
*/
130157
public static void main(String args[]) {
158+
/* Set the Nimbus look and feel */
159+
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
160+
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
161+
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
162+
*/
131163
try {
132164
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
133165
if ("Nimbus".equals(info.getName())) {
@@ -144,14 +176,19 @@ public static void main(String args[]) {
144176
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
145177
java.util.logging.Logger.getLogger(Server_Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
146178
}
179+
//</editor-fold>
180+
181+
/* Create and display the form */
147182
java.awt.EventQueue.invokeLater(new Runnable() {
148183
public void run() {
149184
new Server_Main().setVisible(true);
150185
}
151186
});
152187
}
153188
private int pn;
189+
// Variables declaration - do not modify//GEN-BEGIN:variables
154190
private javax.swing.JLabel jLabel1;
155191
private javax.swing.JTextField portno;
156192
private javax.swing.JButton start_server;
193+
// End of variables declaration//GEN-END:variables
157194
}

0 commit comments

Comments
 (0)