Sie sind auf Seite 1von 10

import java.awt.*; import java.applet.*; public class aprgm extends Applet { public void paint(Graphics g) { g.drawOval(20,190,90,30); g.drawLine(20,202,60,100); g.

drawLine(108,200,60,100); } } /* <html> <head> <title>aprgm</title></head> <body> <applet code="aprgm.class" width=500 height=500> </applet></body></html>*/

09BCA

import java.awt.*; import java.applet.*; public class bprgm extends Applet { public void paint(Graphics g) { g.drawOval(20,190,90,30); g.drawOval(20,80,90,30); g.drawLine(20,202,20,100); g.drawLine(108,202,108,100); } } /* <html> <head> <title>bprgm</title></head> <body> <applet code="bprgm.class" width=500 height=500> </applet></body></html>*/

import java.awt.*; import java.applet.*; public class cube extends Applet { public void paint(Graphics g) { g.drawRect(100,100,300,300); g.drawRect(200,200,300,300); g.drawLine(100,100,200,200); g.drawLine(400,400,500,500); g.drawLine(400,100,500,200); g.drawLine(100,400,200,500); } } /* <html> <head> <title>cube</title></head> <body> <applet code="cube.class" width=500 height=500> </applet></body></html>*/

import java.awt.*; import java.applet.*; public class cs extends Applet { public void paint(Graphics g) { g.drawOval(70,70,60,60); g.drawRect(50,50,100,100); } } /* <html> <head> <title>cs</title></head> <body> <applet code="cs.class" width=500 height=500> </applet></body></html>*/

import java.awt.*; import java.applet.*; public class sc extends Applet { public void paint(Graphics g) { g.drawOval(70,70,120,120); g.drawRect(100,100,60,60); } } /* <html> <head> <title>sc</title></head> <body> <applet code="sc.class" width=500 height=500> </applet></body></html>*/

import java.net.*; class serverapp { public static int serverPort=997; public static int clientPort=998; public static int buff_size=1024; public static DatagramSocket ds; public static byte buff[]=new byte[buff_size]; public static void server() throws Exception { int pos=0; while(true) { int c=System.in.read(); switch(c) { case -1: System.out.println("server Quits"); return; case '\r': break; case '\n': ds.send(new DatagramPacket (buff,pos,InetAddress.getLocalHost(),clientPort)); pos=0; break; default: buff[pos++]=(byte)c; } } } public static void main(String args[])throws Exception { ds=new DatagramSocket(serverPort); server(); } }

OUTPUT: X:\>javac serverapp.java X:\>java serverapp hi grd BCA

import java.net.*; class clientapp { public static int serverPort=997; public static int clientPort=998; public static int buff_size=1024; public static DatagramSocket ds; public static byte buff[]=new byte[buff_size]; public static void client()throws Exception { while(true) { DatagramPacket p=new DatagramPacket(buff,buff.length); ds.receive(p); System.out.println(new String(p.getData(),0,p.getLength())); } } public static void main(String args[])throws Exception { ds=new DatagramSocket(clientPort); client(); } }

OUTPUT: X:\>javac clientapp.java X:\>java clientapp hi grd BCA

import java.awt.*; import java.applet.*; public class great extends Applet { int a=0,b=0,c=0,d=0; String s1,s2,s3,s; TextField text1,text2,text3; public void init() { text1=new TextField(10); text2=new TextField(10); text3=new TextField(10); add(text1); add(text2); add(text3); text1.setText("0"); text2.setText("0"); text3.setText("0"); } public void paint(Graphics g) { g.drawString("enter 3 integer:",30,70); try { s1=text1.getText(); a=Integer.parseInt(s1); s2=text2.getText(); b=Integer.parseInt(s2); s3=text3.getText(); c=Integer.parseInt(s3); } catch(Exception e) {} d=a+b+c; s=String.valueOf(d); g.drawString("sum:",30,120); g.drawString(s,60,120); if(a>b&&a>c) { g.drawString(s1,30,225);

} else if(b>a&&b>c) { g.drawString(s2,30,225); } else { g.drawString(s3,30,225); } g.drawString("is greater",50,225); } public boolean action(Event e,Object obj) { repaint(); return true; } } /* <html> <head> <title>sum and big</title> </head> <body> <applet code="great.class" width=400 height=400> </applet> </body> </html> */

09BCA

Das könnte Ihnen auch gefallen