//Karel Lember, Jaanus Oks, Ants Rehe, Rain Koor --Programmiga saab vaadata serverite kasutajaid ja seda, kas server, //mida otsite, üldse olemas on. import java.net.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.awt.Color; public class Fingerinfo extends Frame implements ActionListener{ public void paint (Graphics g){ g.setColor(Color.red); g.fillRect(0, 0, getSize().width, getSize().height); } TextField tekst1=new TextField("Kasutaja nimi"); TextArea tekst2=new TextArea("", 30, 50); TextField tekst3=new TextField("Server "); TextArea tekst4=new TextArea("", 50, 80); public Fingerinfo(){ setLayout (new FlowLayout()); setSize(500,600); add(tekst1); add(tekst3); add(tekst2); tekst1.setBackground(Color.black); tekst1.setForeground(Color.white); tekst1.addActionListener(this); tekst3.setBackground(Color.black); tekst3.setForeground(Color.white); tekst3.addActionListener(this); setVisible(true); } public void actionPerformed(ActionEvent e){ try{ String nimi=tekst1.getText(); Socket sc=new Socket(tekst3.getText(), 79); BufferedReader sisse=new BufferedReader( new InputStreamReader(sc.getInputStream()) ); PrintWriter valja=new PrintWriter(sc.getOutputStream(), true); valja.println(nimi); String rida=sisse.readLine(); String tulemus=""; while(rida!=null){ tulemus=tulemus+"\n"+rida; rida=sisse.readLine(); tekst2.setText(tulemus); } }catch(Exception viga){viga.printStackTrace(); tekst3.setText("Viga"); } } public static void main(String argumendid[]) throws Exception{ new Fingerinfo(); } }