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();
    }
}

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











0 comments:

Post a Comment