Documente Academic
Documente Profesional
Documente Cultură
Color;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
public SocketClient(){
text = new JLabel("File to send over socket:");
buttonPerc = new JButton ("Scegli file");
button = new JButton("Invia");
button.addActionListener(this);
buttonPerc.addActionListener(this);
panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setBackground(Color.white);
getContentPane().add(panel);
panel.add("North", text);
panel.add("Center", buttonPerc);
panel.add("South", button);
panel.add(text,BorderLayout.NORTH);
panel.add(buttonPerc,BorderLayout.CENTER);
panel.add(button,BorderLayout.SOUTH);
} //End Constructor
try{
out2.println(f.getName());
out.reset();
out.writeObject(f);
}catch(Exception e){}
try{
String line = in2.readLine();
System.out.println(line);
}
catch (Exception e){
System.out.println("Read failed");
System.exit(1);
}}
if( source ==buttonPerc){
}
catch (UnknownHostException e) {
System.out.println("Unknown host");
System.exit(1);
}
catch (IOException e) {
System.out.println("No I/O"); System.exit(1);
}
}
public static void main(String[] args){
SocketClient frame = new SocketClient();
frame.setTitle("Client Program");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
frame.addWindowListener(l);
frame.pack();
frame.setVisible(true);
frame.listenSocket();
}
}//fine della classe SocketClient