Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Signed-off-by: kalyani chaudhari <138003080+misskalyani@users.noreply.github.com>
  • Loading branch information
misskalyani authored Aug 2, 2024
1 parent c2d7158 commit 2e7150d
Show file tree
Hide file tree
Showing 36 changed files with 1,244 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Applet1/Addition.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<applet code="Addition.class" width="500" height="400">
</applet>
</body>
</html>
31 changes: 31 additions & 0 deletions Applet1/Addition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Addition extends Applet implements ActionListener
{
Label l1,l2,l3;
TextField t1,t2,t3;
Button b1;
public void init()
{
l1=new Label("Enter First No");
l2=new Label("Enter Second No");
l3=new Label("Display Result");
t1=new TextField(10);
t2=new TextField(10);
t3=new TextField(10);
b1=new Button("ADD");
add(l1);add(t1);add(l2);add(t2);add(l3);add(t3);add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t1.getText());
int c=a+b;
}
}
}
6 changes: 6 additions & 0 deletions Applet1/Car.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<applet code="Car" height="500" width="500">
</applet>
</body>
</html>
69 changes: 69 additions & 0 deletions Applet1/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class Car extends Applet implements ActionListener
{
int i=0;
Button b1,b2,b3;
public void init()
{
setLayout(new FlowLayout());
b1=new Button("Next");
b2=new Button("Stop");
b3=new Button("Back");
add(b1);add(b2);add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);

}
public void paint(Graphics g)
{

g.drawRect(100+i,100,200,100);
g.setColor(Color.red);
g.fillRect(100+i,100,200,100);
g.setColor(Color.white);
g.fillOval(100+i,10,10,10);

g.drawRect(300+i,105,20,90);
g.setColor(Color.yellow);
g.fillRect(300+i,105,40,90);

/*g.drawRect(200+i,100,50,50);
g.setColor(Color.pink);
g.fillRect(200+i,100,50,50);*/

g.setColor(Color.black);
g.fillOval(120+i,200,30,30);
g.setColor(Color.black);
g.fillOval(150+i,200,30,30);
g.setColor(Color.black);
g.fillOval(200+i,200,30,30);
g.setColor(Color.black);
g.fillOval(200+i,200,30,30);
g.setColor(Color.black);
g.fillOval(230+i,200,30,30);


}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
for(i=0;i<=1000;i=i+(30))
repaint();
}
if(ae.getSource()==b2)
{
stop();
}
if(ae.getSource()==b3)
{
for(i=0;i<=1000;i=i+(-30))

repaint();
}
}
}
5 changes: 5 additions & 0 deletions Applet1/Car2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<applet code="Car2" width=1200 height=720></applet>
</body>
</html>
86 changes: 86 additions & 0 deletions Applet1/Car2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Car2 extends Applet implements KeyListener
{
void slep()
{
try
{
Thread.sleep(100);
}
catch(Exception ex)
{
}
}
int x=600,y=360;
public void paint(Graphics g)
{

addKeyListener(this);
setBackground(Color.gray);
g.setColor(Color.black);
g.drawOval(x-2,y+15,7,20);
g.fillOval(x-2,y+15,7,20);
g.drawOval(x-2,y+75,7,20);
g.fillOval(x-2,y+75,7,20);
g.setColor(Color.blue);
g.drawRoundRect(x,y,76,105,10,20);
g.fillRoundRect(x,y,76,105,10,20);
g.setColor(Color.black);
g.drawRect(x+7,y+75,62,18);
g.fillRect(x+7,y+75,62,18);
g.setColor(Color.red);
g.drawOval(x+4,y+95,6,9);
g.drawOval(x+66,y+95,6,9);
g.fillOval( x+4,y+95,6,9);
g.fillOval( x+66,y+95,6,9);
g.setColor(Color.black);
g.drawRoundRect(x+7,y+35,63,35,10,20);

g.setColor(Color.yellow);
g.drawOval(x+4,y+1,9,15);
g.drawOval(x+3,y+1,9,15);
g.fillOval(x+63,y+1,9,15);
g.fillOval(x+4,y+1,9,15);

slep();

}
public void keyPressed(KeyEvent ke){
int KeyCode = ke.getKeyCode();

switch(KeyCode)
{
case KeyEvent.VK_UP:
if(y>0)
y=y-1;
break;
case KeyEvent.VK_DOWN:
if(y<getHeight()-105)
y=y+1;
break;
case KeyEvent.VK_LEFT:
if(x>0)
x=x-1;
break;
case KeyEvent.VK_RIGHT:
if(x<getWidth()-76)
x++;
break;
}
repaint();
}

public void keyTyped(KeyEvent ke) {

}

public void keyReleased(KeyEvent ke){
}




}
56 changes: 56 additions & 0 deletions Applet1/Car3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import java.applet.*;
import java.awt.*;

@SuppressWarnings("serial")
public class CarAnimation extends Applet implements Runnable {
private int x = 0;
private int y = 150;
private int speed = 5;
private boolean isMoving = true;

public void init() {
setBackground(Color.WHITE);
}

public void start() {
Thread thread = new Thread(this);
thread.start();
}

public void stop() {
isMoving = false;
}

public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 200, getWidth(), 50); // Road
g.setColor(Color.WHITE);
int lineY = 225;
for (int i = 0; i < getWidth(); i += 50) {
g.fillRect(i, lineY, 30, 5); // Dashed lines
}
g.setColor(Color.RED);
g.fillRect(x, y, 100, 50); // Car body
g.setColor(Color.PURPLE);
g.fillRect(x + 10, y - 40, 80, 50); // Car roof
g.setColor(Color.BLUE);
g.fillOval(x + 10, y + 40, 30, 30); // Left wheel
g.fillOval(x + 60, y + 40, 30, 30); // Right wheel
}

public void run() {
while (isMoving) {
x += speed;
if (x > getWidth()) {
x = -100; // Reset the car's position
}
repaint();
try {
Thread.sleep(50); /* Sleep for smooth animation */
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

24 changes: 24 additions & 0 deletions Applet1/Gdemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.awt.*;
import java.applet.*;
public class Gdemo extends Applet
{
public void paint(Graphics g)
{
g.drawString("Welcome Kalyani...!",150,10);


g.drawLine(10,20,300,500);
g.drawRect(100,50,100,300);
g.fillRect(250,50,100,300);
g.drawRoundRect(400,50,100,300,50,50);
g.drawOval(100,400,100,100);
g.setColor(Color.pink);
g.fillArc(300,300,100,100,200,200);
g.setColor(Color.red);
int a[]={100,550,300,600,50};
int b[]={100,150,200,300,500};
g.drawPolygon(a,b,5);
}
}
/*<applet code="Gdemo" height="500" width="500">
</applet>*/
6 changes: 6 additions & 0 deletions Applet1/GraphicsDemo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body bgcolor="red" >
<applet code="GraphicsDemo" width="500" height="400">
</applet>
</body>
</html>
22 changes: 22 additions & 0 deletions Applet1/GraphicsDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import java.applet.*;
import java.awt.*;
public class GraphicsDemo extends Applet
{
public void paint(Graphics g)
{
Font f1=new Font("Arial",Font.BOLD,25);
g.setFont(f1);
g.drawString("Welcome Kalyani",100,100);
g.drawRect(100,100,200,50);//x y width height
g.drawOval(100,200,100,150);//x y w h
g.drawLine(100,200,300,300);//x1 y1 x2 y2
g.setColor(Color.red);
g.fillOval(300,200,100,100);
g.setColor(Color.pink);
g.fillRect(100,300,200,50);
g.drawArc(100,100,200,200,90,360);
}
}


24 changes: 24 additions & 0 deletions Applet1/Jtable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.awt.*;
import javax.swing.*;
class table extends JFrame
{
JTable tbl;
table()
{
setVisible(true);
setSize(500,500);
setLayout(new FlowLayout());
String head[]={"ENO","NAME","SALARY"};
String data[][]={{"101","sai","60000"},
{"102","ram","78000"},
{"103","om","67000"}};
tbl=new JTable(data , head);
// add(tbl);
JScrollPane js=new JScrollPane(tbl);
add(js);
}
public static void main(String ar[])
{
new table();
}
}
11 changes: 11 additions & 0 deletions Applet1/car1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple Car Applet</title>
</head>
<body>
<applet code="car1.class" width="300" height="200">
Your browser does not support Java applets.
</applet>
</body>
</html>
Loading

0 comments on commit 2e7150d

Please sign in to comment.