Social Icons

Thursday, 14 November 2013

Moving fan using java Applet

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Banner5" width=500 height=500>
</applet>
*/
public class Banner5 extends Applet implements Runnable,MouseListener,MouseMotionListener{

Thread t = null;

Thread t1 = null;
int x,y,state;
boolean stopFlag,st1;
// Set colors and initialize thread.
public void init() {
setBackground(Color.cyan);
setForeground(Color.red);
addMouseListener(this);
addMouseMotionListener(this);
}

public void mouseClicked(MouseEvent me)
{
t1 = new Thread(this);
stopFlag = false;
t1.start();

}
public  void mouseEntered(MouseEvent me)
{
t = new Thread(this);
stopFlag = false;
t.start();



}
public  void mouseExited(MouseEvent me)
{
stopFlag = true;
st1=true;
showStatus("Exited");
}

public  void mousePressed(MouseEvent me)
{}
public  void mouseReleased(MouseEvent me)
{}







public void mouseMoved(MouseEvent me)
{
 //repaint();

showStatus("hello");
}



public void run() {
char ch;

for( ; ; ) {
try {



repaint();
Thread.sleep(300);
x=x+10;
y=y+10;



if(stopFlag)
break;
} catch(InterruptedException e) {}
}
}


public void mouseDragged(MouseEvent me)
{

}















// Start thread
public void start() {
t = new Thread(this);
stopFlag = true;
t.start();
x=0;
}

// Pause the banner.
public void stop() {
stopFlag = true;
t = null;
}
// Display the banner.
public void paint(Graphics g) {

g.fillArc(100, 40, 100, 100, 0+x, 45);
g.fillArc(100, 40, 100, 100, 120+x, 45);
g.fillArc(100, 40, 100, 100, 240+x, 45);


g.fillArc(100, 200, 100, 100, 240-y, 45);
g.fillArc(100, 200, 100, 100, 120-y,45);
g.fillArc(100, 200, 100, 100, 0-y, 45);

}
}

Saturday, 26 October 2013

Right Moving String in Java Applet

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*

<applet code=jitender width=400 height=400>
</applet>

*/


public class jitender extends Applet implements Runnable
{
Thread t=null;
boolean stopflag;
String msg,ch1;





  public void init()
  {
  setBackground(Color.cyan);
  setForeground(Color.red);
 }

 public void start()
  {
  msg="A simple jitender moving";
if(msg==null)
 {
  msg="message not found";
 }
msg=" "+msg;
 t=new Thread(this);
 stopflag=false;
  t.start();
}

public void run()
{
char ch;
String ch1;

 char p1[]=msg.toCharArray();
for( ; ;)
{
 try
   {
repaint();
Thread.sleep(250);

ch=p1[p1.length-1];

for(int i=p1.length-1;i>0;i--)
{
   p1[i]=p1[i-1];
 }
 p1[0]=ch;
ch1= String.valueOf(p1);
 msg=ch1;












   if(stopflag)
    {
    break;
     }


   }catch(InterruptedException e){}


}

}

public void stop()
{
   stopflag=true;
    t=null;
}

public void paint(Graphics g)
{
g.drawString(msg,50,30);
}

}

Sunday, 20 October 2013

dbms pl/sql curser

set serveroutput on;
DECLARE
   total_rows number(2);
BEGIN
   UPDATE e1111
   SET esalary = esalary + 500;
   IF sql%notfound THEN
      dbms_output.put_line('no customers selected');
   ELSIF sql%found THEN
      total_rows := sql%rowcount;
      dbms_output.put_line( total_rows || ' customers selected ');
   END IF;
END;

Sunday, 29 September 2013

Exception handling in java

class ex
{

 public static int quotient(int a,int b)
{

   if(b==0)
  {
  throw new ArithmeticException("divide by zero") ;
  }
 return a/b;


}


 public static void main(String args[])
 {
 int c;
 int a=5,b=0;
 

       
  try
  {
   c=quotient(a,b);
  System.out.println("the value of a/b is "+c);

  }



 catch(ArithmeticException e)
 {
  System.out.println("the b value can not be negative :");
 System.out.println(" :"+e.getMessage());
  System.out.println(" :"+e.toString());

  e.printStackTrace();
 }


     finally
       {
          System.out.println("hello finally is executed ");
 
              }            


}


}
 

Sample Text

Sample text

 
Just Programming Cse DriveReputation Management