import java.applet.*;
import java.awt.*;
/*<applet code="banner" width=500 height=500>
</applet>*/
public class banner extends Applet implements Runnable
{
Label l1,l2;
public void start()
{
Thread t=new Thread(this);
t.start();
}
public void run()
{
setLayout(null);
setForeground(Color.white);
Font f=new Font("TIMES NEW ROMAN",Font.BOLD,20);
l1= new Label("THIS IS A BANNER");
l2=new Label("CREATED BY KRISHNA PRASAD");
l1.setFont(f);
l2.setFont(f);
l1.setBounds(100,100,200,30);
l2.setBounds(100,150,400,30);
showStatus("Banner Applet");
try
{
while(true)
{
add(l1);
setBackground(Color.pink);
Thread.sleep(500);
remove(l1);
add(l2);
setBackground(Color.magenta);
Thread.sleep(500);
remove(l2);
}
}
catch(InterruptedException e)
{
}
}
}
I KRISHNAPRASAD PURSUING MY B.TECH IN C.R.REDDY COLLEGE OF ENGINEERING TRADE COMPUTER SCIENCES AND ENGINEERING. I'M HAPPY TO PRESENT ALL TYPE OF PROGRAMS. I HOPE U UTILISE THIS BLOG AND ENJOY YOUR PROGRAMMING. THESE PROGRAMS ARE BEST COMPILED IN TURBO C++ COMPILERS AND SUN JAVA COMPILERS
Friday, October 29, 2010
BANNER APPLET
MOUSE EVENTS
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<applet code="mouse" width=500 height=500>
</applet>*/
public class mouse extends Applet implements MouseListener, MouseMotionListener
{
public void init()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mouseEntered(MouseEvent e)
{
setBackground(Color.pink);
showStatus("mouse entered");
}
public void mouseExited(MouseEvent e)
{
setBackground(Color.black);
showStatus("mouse exited");
}
public void mouseClicked(MouseEvent e)
{
setBackground(Color.blue);
showStatus("mouse Clicked");
}
public void mouseDragged(MouseEvent e)
{
setBackground(Color.green);
showStatus("mouse dragged");
}
public void mousePressed(MouseEvent e)
{
setBackground(Color.red);
showStatus("mouse pressed");
}
public void mouseReleased(MouseEvent e)
{
setBackground(Color.yellow);
showStatus("mouse released");
}
public void mouseMoved(MouseEvent e)
{
//showStatus("mouse moved after entering");
}
}
Thursday, October 14, 2010
JAVA CALCULATOR
import java.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<applet code="calculator" width=500 height=500>
</applet>*/
public class calculator extends Applet implements ActionListener
{
Label l1,l2;
Button b1,b2,b3,b4,b5;
TextField t1,t2;
public void init()
{
setLayout(null);
l1=new Label("number");
l2=new Label("number");
b1=new Button("add+");
b2=new Button("sub- ");
b3=new Button("mul*");
b4=new Button("div/");
b5=new Button("clear");
t1=new TextField(20);
t2=new TextField(20);
add(l1);
l1.setBounds(10,10,60,40);
add(l2);
l2.setBounds(10,70,60,40);
add(t1);
t1.setBounds(90,10,100,40);
add(t2);
t2.setBounds(90,70,100,40);
add(b1);
b1.setBounds(30,200,50,50);
add(b2);
b2.setBounds(100,200,50,50);
add(b3);
b3.setBounds(170,200,50,50);
add(b4);
b4.setBounds(240,200,50,50);
add(b5);
b5.setBounds(350,200,50,50);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
float a,b,c;
if(e.getSource()==b5)
{
t1.setText("");
t2.setText("");
t1.requestFocus();
}
a=Float.parseFloat(t1.getText());
b=Float.parseFloat(t2.getText());
showStatus("calculator");
if(e.getSource()==b1)
{
c=a+b;
t1.setText(""+c);
t2.setText("");
t2.requestFocus();
}
else if(e.getSource()==b2)
{
c=a-b;
t1.setText(""+c);
t2.setText("");
t2.requestFocus();
}
else if(e.getSource()==b3)
{
c=a*b;
t1.setText(""+c);
t2.setText("");
t2.requestFocus();
}
else if(e.getSource()==b4)
{
c=a/b;
t1.setText(""+c);
t2.setText("");
t2.requestFocus();
}
}
}
Subscribe to:
Posts (Atom)
