Wednesday, March 24, 2010

Silent Auction Basket




import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class DueCerchi extends JPanel{
    Color colore1=Color.YELLOW;
    Color colore2=Color.RED;
    String numero="";
    String n="";
    int y;
    int a;
    int[][]coord={{110, 80},{150, 100},{170, 130},{170, 170},{150, 210},{115, 230},     {80, 230},{40, 210},{10, 170},{10, 130},{30, 100},{70,80}};     public void setColore1(Color c1){         colore1=c1;
    }         colore2= c2;     }     public void paintComponent(Graphics g){         g.setColor(colore1);         g.fillOval(0,50,200,200);         g.drawLine(100,250,100,50);

        g.drawLine(0,150,200,150);
        g.drawLine(10,200,190,100);
        g.drawLine(10,100,190,200);
        g.drawLine(50,60,150,240);
        g.drawLine(50,240,150,60);
        int j;
        for(int i=0;i<12;i++){
            j=i+1;
            n=numero+j;
            g.drawString(n,coord[i][0],coord[i][1]);
            if(i==y){
                g.fillOval(coord[i][0]+5,coord[i][1],10,10);
                System.out.println("La mia y e:"+y);
            }
            if(a==1){
                g.fillOval(coord[i][0]+5,coord[i][1],10,10);
            }
        }

        a=0;

        g.setColor(colore2);
    }
    public int getY(int a){
        y=a;
        return y;}
Hide
public int (int d) {
, y = d;
return y;}

public int show () {&
# 160; a = 1;
        return a;
    }
}

---------------------------------------------------------------------

import java.io.*;
import java.net.*;
public class ServerSemplice {
    public void go(){
        try{
            S1 = new ServerSocket ServerSocket (12), / / \u200b\u200bI create a listening port
while (true) {/ / if someone asks to enter do I create a direct connection between server and client
& # 160; ; s1.accept Socket socket = (), / / \u200b\u200bthe socket is a socket
& # 160 / / broadcast data to the client:
& # 160; PrintWriter write = new PrintWriter (presa.getOutputStream ());// class that sends data in the virtual link
& # 160; getSuggerimenti int s = ();
& # 160; scrivi.println (s) / / send the string s in the channel
scrivi.close ();
& # 160; System.out.println(s);
            }
        }
        catch(IOException ex){
            ex.printStackTrace();
        }

    }
    private int getSuggerimenti(){
        double r1=Math.random()*12;
        int r=(int)r1;
        return r;

    }

    public static void main(String args[]){

        ServerSemplice serv=new ServerSemplice();

        serv.go();
    }
}

 

---------------------------------------------------------------------

import java.awt.event.*;
import java.io. *;
import java.net .*;
import java.util .*;
import javax.swing .*;
import java.awt .*;
TestaDueCerchi {public class
int y;
BufferedReader reader;
Socket sock;
& # 160; PrintWriter writer;

JFrame f1 = new JFrame ("disegno1");

DueCerchi d1 = new DueCerchi ();
JButton b = new JButton ("Ricevi");
JPanel p1 = new JPanel (); Hide
JButton = new JButton ("Hide");
mostra JButton = new JButton ("Mostra");
JTextField t1;
JTextArea a1;
JScrollPane scrollPane;
    public TestaDueCerchi(){
        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        d1.setColore1(Color.YELLOW);

        d1.setColore2(Color.BLUE);

        f1.add(BorderLayout.SOUTH,b);

b.addActionListener (new Button ());

& # 160; JFrame f1 = new JFrame ("Game Chat");

& # 160; f1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

& # 160; a1 = new JTextArea (20,50);
t1 = new JTextField (200);
JButton b1 = new JButton (" invia il messaggio ");
b.addActionListener (new Bottone ( ));
nascondi.addActionListener (new Hide ());
p1.setLayout (new GridLayout (2,3));
= new ScrollPane JScrollPane (a1);
p1.add (ScrollPane, BorderLayout. CENTER);
p1.add (t1);
p1.add (b1) ;
p1.add (BorderLayout.SOUTH, d1);
p1.add (hide);
& # 160; p1.add (b);
f1.add (BorderLayout. SOUTH shows);
mostra.addActionListener (new Display () );
f1.add (p1);
; f1.pack();
          f1.setVisible(true);
        }
    public class Bottone implements ActionListener{
            public void actionPerformed(ActionEvent e){
                go ();
& # 160; p1.repaint ();


}} public class Hide implements ActionListener {
public void actionPerformed(ActionEvent e){
            d1.nascondi(33);
            p1.repaint();
        }
    }
    public class View implements ActionListener {
public void actionPerformed (ActionEvent e) {
& # 160; d1.mostra ();
& # 160; p1.repaint ();



}} public void go () {# &
160; try {
& # 160 / / connect to server (ip, port)
for (int i = 0; i \u0026lt;1; i + +) {
& # 160; Socket s = new Socket ("localhost", 12);
& # 160; InputStreamReader r = new InputStreamReader (s.getInputStream ());
& # 160; BufferedReader reader = new BufferedReader (r);
/ / statement to read from the server
& # 160; reader.readLine String tip = ();
& # 160; System.out.println ("Tip: "+ Hint);
, y = Integer.parseInt (hint);
; d1.getY (y);
& # 160; reader.close ();
}
        }catch(IOException ex){
            ex.printStackTrace();
        }
    }

    public static void main(String[]args){
        TestaDueCerchi TestaDueCerchi d = new ();}

}



------------------ -------------------------------------------------- -








Tuesday, March 23, 2010

Dora Party Ideas Blog

Base in Snakes Chat


In this first version by pressing the button you can to move the ball in the cells of the scoreboard

---------------- -------------------------------------------------- ---

import java.awt.event .*;
import java.io. *;
import java.net .*;
import java.util .*;
import javax.swing .*;
import java. awt .*; Public class

TestaDueCerchi

{int y;
BufferedReader reader;
Socket sock;
PrintWriter writer;

JFrame f1 = new JFrame ("disegno1");

& # 160; DueCerchi DueCerchi d1 = new ();

JButton b = new JButton ("Get");

& # 160; public TestaDueCerchi(){

        f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        f1.add(BorderLayout.CENTER,d1);         d1.setColore1(Color.YELLOW); clip_image002         d1.setColore2(Color.BLUE);         f1.add (BorderLayout.SOUTH, b);

b.addActionListener (new Button ()); & # 160; f1.setVisible (true);

}

    public class Bottone implements ActionListener{

            public void actionPerformed(ActionEvent e){

                go();

                f1.repaint ();
;}}


public void go () {&
# 160; try {
/ / connect to server (ip, port)
for (int i = 0, i \u0026lt;1; i + +) {
Socket s = new Socket ("localhost", 12);
; InputStreamReader r = new InputStreamReader (s.getInputStream ());
BufferedReader reader = new BufferedReader (r);
/ / education to read from the server
; reader.readLine String tip = ();
; System.out.println ("Hint:" + hint);
& # 160, y = Integer.parseInt (hint);
& # 160; d1.getY (y);
; reader.close ();
            }
        }catch(IOException ex){
            ex.printStackTrace();
        }
    }
    public static void main(String[]args){
        TestaDueCerchi d=new TestaDueCerchi();
    }
}

---------------------------------------------------------------------

import java.awt.event.*;
import java.io.*;

import java.net.*;

import java.util.*;
import javax.swing.*;
import java.awt.*;
public class DueCerchi extends JPanel{
    Color colore1 = Color.Yellow;
colore2 Color = Color.Red;
String numero = "";
& # 160; String s = "";
int y, int
[ ] [] coord = {{210, 180}, {250, 200}, {270, 230}, {270, 270}, {250, 310}, {215, 330},
, {180, 330}, {140, 310}, {110, 270}, {110, 230}, {130, 200}, {170.180}};
    public void setColore1(Color c1){
        colore1=c1;
    }

    public void setColore2(Color c2){
        colore2= c2;
    }
    public void paintComponent(Graphics g){
        g.setColor(colore1);
        g.fillOval(100,150,200,200);
        g.setColor(colore2);

        g.fillOval(150,200,100,100);

        g.drawLine(200,350,200,150);

        g.drawLine(100,250,300,250);

        g.drawLine(110,300,290,200);
        g.drawLine(110,200,290,300);
        g.drawLine(150,160,250,340);
        g.drawLine(150,340,250,160);
        int j;
        for(int i=0;i<12;i++){
            j=i+1;
            n=numero+j;
            g.drawString(n,coord[i][0],coord[i][1]);
            if(i==y){
                g.fillOval(coord[i][0]+5,coord[i][1],10,10);
                System.out.println ("La mia ye:" + y);
;}}

& # 160 / / (x, y, w, h)
; g.setColor (colore2);
g.fillOval(150,200,100,100);

    }
    public int getY(int a){
        y=a;
        System.out.print(a);
        return y;
    }

}

---------------------------------------------------------------------

import java.io. *;
import java.net .*;
public class ServerSemplice
{public void go () {
try {
, s1 = new ServerSocket ServerSocket (12), / / \u200b\u200bI create a listening port
; while (true) {/ / if someone asks to enter do I create a direct connection between server and client
& # 160; s1.accept Socket socket = ( ), / / \u200b\u200bthe socket is a socket
/ / transmission data to the client:
PrintWriter write = new PrintWriter (presa.getOutputStream ());// class that sends the data to the virtual link
& # 160; getSuggerimenti int s = ();
& # 160; scrivi.println (s) / / send the string in the channel # s &
160; scrivi.close ();
& # 160; System.out.println (s )
}
        }

        catch(IOException ex){

            ex.printStackTrace();
        }

    }
    private int getSuggerimenti(){
        double r1=Math.random()*12;

        int r=(int)r1;

        return r;

    }

    public static void main(String args[]){

        ServerSemplice serv=new ServerSemplice();

        serv.go();
    }
}

---------------------------------------------------------------------











Tuesday, March 9, 2010

Suspension Polaris Xtra 10 Xlt

java



Server


import java.io.*;
import java.net.*;
import java.util.*;
public class ServerSemplice {
    PrintWriter[] clienti=new PrintWriter[20]; Public class
ElaboraCliente implements Runnable {BufferedReader reader
= null;
Socket sock = null;
/ / create the input stream
& # 160; public ElaboraCliente (Socket c) {

            try{

            sock=c;

            lettore=new BufferedReader(new InputStreamReader(sock.getInputStream()));

            }catch(Exception ex){                 ex.printStackTrace(); Cattura1             }         }         @ Override public void run () {& Cattura # 160; String message; ;

try {while ( (message = lettore.readLine ())!= null) { String ind indirizzo.toString = ();

& # 160; String m = ind + "" + message;

& # 160; talkative (m) &

# 160;} &

# 160; }catch(Exception ex){

                ex.printStackTrace();
            }
        }
    }
    public void go () {try {

/ / door listening
ServerSocket door = new ServerSocket (4242);
int i = 0;
while (true) {
/ / create the connection with the customer who knocked on the door
Socket portone.accept door = ();
/ / create the stream to write messages to the client
& # 160; PrintWriter writer = new PrintWriter (portina. getOutputStream ());
/ / Save this stream into an array of output
; customers [i] = writer;
& # 160; i + +;
& # 160; //........
& # 160 / / create an input stream for that client and I start to receive your messages
/ / send the received message to all clients
& # 160; Thread t=new Thread(new ElaboraCliente(portina));
                t.start();
                }
        }catch(Exception ex) {ex
. printStackTrace ();}


} & # 160; public void talker (String message) {
for (int i = 0; i \u0026lt;20; i + +) {
; if (customers [i]! = null) {
& # 160; try {
& # 160; customers [i]. println (message);
customers [i]. flush ();
System.out.println("Ho spedito il messaggio");
            }catch(Exception ex){
                ex.printStackTrace();
            }
        }
    }
}
    public static void main(String args[]){
        ServerSemplice s=new ServerSemplice();
        s.go();
    }
}

 

Client

import java.awt .*;
import javax.swing .*;
import java.awt.event .*;
import java.io. *;
import java.net .*;
import java. util .*;

public class Client {BufferedReader reader;
Socket sock;
PrintWriter writer;
JTextField t1;
JTextArea a1;
& # 160; JScrollPane ScrollPane;
public void window () {
JFrame f1 = new JFrame (" simple chat ");
f1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
& # 160; JPanel p1 = new JPanel ();
a1 = new JTextArea (20,50);
t1 = new JTextField (200);
JButton b1 = new JButton ("invia il messaggio"); ;
p1.setLayout (new GridLayout (3,1));
& # 160; scrollPane = new JScrollPane (a1);
p1.add scrollPane ("BorderLayout . CENTER);

p1.add(t1);

      p1.add(b1);

      b1.addActionListener(new InviaMessaggio());

      f1.add(p1);

      f1.setSize(500,500);

      f1.setVisible(true);
      Thread tt=new Thread(new InarrivoDalServer ());
creaCollegamento ();
; tt.start ();}

public void creaCollegamento () {try {

& # 160; sock = new Socket ("192.168.3.18", 4242);
lettore = new BufferedReader (new InputStreamReader (sock.getInputStream ()));
writer = new PrintWriter (sock.getOutputStream ());
System.out.println ("Connection established") ;
} catch (Exception ex) {ex.printStackTrace
();}


} & # 160; implements ActionListener {public class InviaMessaggio
public void actionPerformed (ActionEvent e) { Try {

& # 160; scrittore.write (t1.getText ());
scrittore.println (t1.getText ());
& # 160; scrittore.flush () / / reset the content so as not to send the same message
} catch (Exception ex) {&
# 160; ex.printStackTrace ();

t1.setText} ( "");


}} public class InarrivoDalServer implements Runnable {
; public void run () {# &
160; String message;
try {
; while ((message = lettore.readLine ())!= null) {
a1.append (message + "\\ n");
& # 160; System.out.println ("read the message:" + message);
;}
;} catch (Exception ex) {&
# 160; ex.printStackTrace();
            }
        }
}
      public static void main(String args[]){
          Client cc=new Client();
          cc.finestra ();}

}