import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class A2P3 extends Applet implements AdjustmentListener,ActionListener { Scrollbar scrb; int i; String s; Button b1; public String baction; Label l1; Graphics g; public void init(){ scrb=new Scrollbar(Scrollbar.HORIZONTAL, 10,10,1,110); add(scrb); scrb.addAdjustmentListener(this); b1=new Button("Draw Line"); add(b1); b1.addActionListener(this); l1=new Label("Current Value is "); add(l1); } public void adjustmentValueChanged(AdjustmentEvent e) { i=e.getValue(); l1.setText("Current Value is "+i); } public void actionPerformed(ActionEvent e) { baction = e.getActionCommand(); } public void paint(Graphics g) { if (baction=="Draw Line") g.drawLine(10,40,i,40); } } Code (markup): On clicking the button "Draw Line", i want the prg to draw a line, with width the value of the scrollbar. Any idea whats going wrong ?