Pages

Largest Programme Of Core Java....


import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.awt.List;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.concurrent.Executors;
import javax.swing.JButton;
public class action extends Applet implements ActionListener
{
int r, g, b, x, y;
Label l1, l2, l3, l4, l5,l6,l7;
TextField t1, t2, t3, t4, t5, t6,t7,t8;
JButton jb;
Button b1, b2, b3, b4 ,b5, b6, b7, b8,b9,b10,b11,b12,b13,b14,b15;
List L;
public void init()
{
r=g=b=0;
x=800;
y=200;
setLayout(null);
L=new List(5,false);
add(L);
L.add("No. 1");
L.add("No. 2");
L.add("No. 3");
L.add("No. 4");
L.add("No. 5");
L.addActionListener(this);
l5 = new Label("Password");
l1 = new Label("Enter p");
l2 = new Label("Enter r");
l4 = new Label("Enter t");
l3 = new Label("Click On Calculate ");
l6 = new Label("www.");
l7 = new Label(".com");
t1 = new TextField();
t2 = new TextField();
t3 = new TextField();
t4 = new TextField();
t5 = new TextField();
t6 = new TextField();
t7 = new TextField();
t8 = new TextField();
t5.setEchoChar('*');
jb = new JButton("GOOGLE");
b1 = new Button(" Calculate ");
b2 = new Button(" RED ");
b3 = new Button(" Blue ");
b4 = new Button(" Green ");
b5 = new Button("Show");
b6 = new Button("BACKGROUND BRIGHTER");
b7 = new Button("Clockwise");
b8 = new Button("Anticlockwise");
b9 = new Button("Reset");
b10 = new Button("Count");
b11 = new Button("Add");
b12 = new Button("Remove");
b13=new Button("google");
b14=new Button("Notepad");
b15=new Button("GO");
add(jb);
add(b14);
add(t8);
add(b15);
add(l1);
add(t1);
add(l2);
add(t2);
add(l4);
add(l6);
add(l7);
add(t4);
add(l3);
add(b1);
add(t3);
add(b2);
add(b3);
add(b4);
add(l5);
add(t5);
add(b5);
add(t6);
add(b6);
add(b7);
add(b8);
add(b9);
add(b10);
add(b11);
add(b12);
add(t7);
add(b13);
jb.setBounds(800, 30, 100, 20);
b1.setBounds(20,490,100,20);
b2.setBounds(130,490,100,20);
b3.setBounds(240,490,100,20);
b4.setBounds(350,490,100,20);
L.setBounds(10,180,100,100);
l1.setBounds(20,20,100,20);
l2.setBounds(20,50,100,20);
l4.setBounds(20,90,100,20);
l3.setBounds(20,130,100,20);
t1.setBounds(140,20,100,20);
t2.setBounds(140,50,100,20);
t4.setBounds(140,90,100,20);
t3.setBounds(140,130,100,20);
l5.setBounds(500, 20, 100, 20);
t5.setBounds(600, 20, 100, 20);
b5.setBounds(500, 50, 100, 20);
t6.setBounds(600, 50, 100, 20);
b6.setBounds(500, 90, 200, 20);
b8.setBounds(700, 550, 100, 20);
b9.setBounds(800, 550, 100, 20);
b7.setBounds(900, 550, 100, 20);
b10.setBounds(140, 300, 100, 20);
b11.setBounds(140, 330, 100, 20);
b12.setBounds(140, 360, 100, 20);
t7.setBounds(10, 310, 100, 20);
b13.setBounds(400, 20, 100, 20);
b14.setBounds(400, 50, 100, 20);
t8.setBounds(430, 400, 100, 20);
b15.setBounds(710, 400, 20, 20);
l6.setBounds(400, 400, 30, 20);
l7.setBounds(540, 400, 30, 20);
l1.setBackground(Color.RED);
l1.setForeground(Color.BLUE);
l2.setBackground(Color.RED);
l2.setForeground(Color.BLUE);
l3.setBackground(Color.RED);
l3.setForeground(Color.BLUE);
l4.setBackground(Color.RED);
l4.setForeground(Color.BLUE);
b1.setBackground(Color.RED);
b1.setForeground(Color.BLUE);
b2.setBackground(Color.RED);
b3.setBackground(Color.blue);
b4.setBackground(Color.green);
b5.setBackground(Color.green);
b6.setBackground(Color.ORANGE);
b13.setBackground(Color.blue);
//setBackground(Color.yellow);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b10.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
b13.addActionListener(this);
b14.addActionListener(this);
b15.addActionListener(this);
jb.addActionListener(this);
// URL u=getDocumentBase();
// Image i=getImage(u, "file:///E:/New%20folder/428817_329971110429317_670594489_n.jpg");
b4.setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
int d=Integer.parseInt(t4.getText());
int c=(a*b*d)/100;
String s=String.valueOf(c);
t3.setText(s);
}
if(e.getSource()==b2)
{
setBackground(Color.RED);
b4.setVisible(true);
b2.setVisible(false);
}
if(e.getSource()==b3)
{
setBackground(Color.blue);
b2.setVisible(true);
b4.setVisible(false);
}
if(e.getSource()==b4)
{
setBackground(Color.green);
}
if(e.getSource()==b5)
{
String p=(t5.getText());
t6.setText(p);
}
if(e.getSource()==b6)
{
r=r+10;
g=g+10;
b=b+10;
Color c=new Color(r, g, b);
setBackground(c);
}
if(e.getSource()==b7 && y<=490)
{
x=x+10;
y=y+10;
}
if(e.getSource()==b8 && y<=490)
{
x=x-10;
y=y+10;
}
if(e.getSource()==b9)
{
x=800;
y=200;
}
if(e.getSource()==b10)
{
int c1=L.getItemCount();
String c2=String.valueOf(c1);
t7.setText(c2);
}
if(e.getSource()==b11)
{
String s1=t7.getText();
L.add(s1);
}
if(e.getSource()==b12)
{
String s1=t7.getText();
L.remove(s1);
}
if(e.getSource()==b13)
{
try
{
String[] args = {"cmd","/c","start","www.google.co.in"};
//Runtime rt = Runtime.getRuntime();
//ProcessBuilder pb = new ProcessBuilder(args);
//Process pr = pb.start();
Process p=Runtime.getRuntime().exec(args);
}
catch (Exception ee)
{
System.out.println(ee.getMessage());
}
}
if(e.getSource()==b14)
{
try
{
Process q=Runtime.getRuntime().exec("notepad.exe");
}
catch (Exception ee)
{
System.out.println(ee.getMessage());
}
}
if(e.getSource()==b15)
{
try
{
String s2=t8.getText();
String s3="www."+s2+".com";
String[] args = {"cmd","/c","start",s3};
//Runtime rt = Runtime.getRuntime();
ProcessBuilder pb = new ProcessBuilder(args);
Process pr = pb.start();
}
catch (Exception ee)
{
System.out.println(ee.getMessage());
}
}
if(e.getSource()==jb)
{
try
{
String[] args = {"cmd","/c","start","www.google.co.in"};
//Runtime rt = Runtime.getRuntime();
//ProcessBuilder pb = new ProcessBuilder(args);
//Process pr = pb.start();
Process p=Runtime.getRuntime().exec(args);
}
catch (Exception ee)
{
System.out.println(ee.getMessage());
}
}
repaint();
}
public void paint(Graphics g)
{
if(L.getSelectedIndex()==0)
{
setBackground(Color.yellow);
}
if(L.getSelectedItem()=="No. 2")
{
setBackground(Color.cyan);
}
if(L.getSelectedItem()=="No. 3")
{
setBackground(Color.BLUE);
}
if(L.getSelectedItem()=="No. 4")
{
setBackground(Color.gray);
}
if(L.getSelectedItem()=="No. 5")
{
setBackground(Color.green);
}
URL u=getDocumentBase();
Image i=getImage(u, "file:///E:/New%20folder/428817_329971110429317_670594489_n.jpg");
g.drawImage(i, 0, 0, 1350, 650, this);
g.drawLine(x, y, 800, 500);
}
}

No comments:

Post a Comment