Monday, 4 May 2015

SCROLLBAR PROGRAM IN JAVA



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

/**
<applet code=”ScrollDemo.class” width=500 height=500>
</applet>
*/

public class ScrollDemo extends Applet implements AdjustmentListener
{
Scrollbar red,green,blue;
Color c;
Object o;

public void init();
{
red=new Scroll(Scrollbar.HORIZONTAL,1,0,1,255);
green=new Scroll(Scrollbar.HORIZONTAL,1,0,1,255);
blue=new Scroll(Scrollbar.HORIZONTAL,1,0,1,255);

red.addAdjustmentListener(this);
green.addAdjustmentListener(this);
blue.addAdjustmentListener(this);

add(red);
add(green);
add(blue);
}

public void adjustmentValueChanged(AdjustmentEvent e)
{
c=new Color(red.getValue(),blue.getValue(),green.getValue());
setBackground(c);
}
}


No comments:

Post a Comment