Java Applet ScrrollBar Kullanımı
import java.applet.Applet;
import java.awt.Graphics;
//import java.awt.Image;
import java.awt.*;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JOptionPane;
public class cetvel extends Applet implements AdjustmentListener {
int CetvelBoyu=1000;
int CetvelBaslangic=10;
Scrollbar Olcer=new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 100);
Label CetvelKonumYaz=new Label(Integer.toString(Olcer.getMaximum()/2));
public void init() {
setLayout(null);
CetvelKonumYaz.setLocation(CetvelBoyu/2, 170);
CetvelKonumYaz.setSize(10, 20);
add(CetvelKonumYaz);
Olcer.setLocation(CetvelBaslangic, 150);
Olcer.setSize(CetvelBoyu, 20);
add(Olcer);
Olcer.addAdjustmentListener(this);
Olcer.setValue(Olcer.getMaximum()/2);
}
public void adjustmentValueChanged(AdjustmentEvent Nesne){
CetvelKonumYaz.setText(Integer.toString(Konum));
}
public void paint(Graphics Ekran){
//JOptionPane.showMessageDialog(this, getCodeBase());
Image Cetvel=getImage(getCodeBase(), "cetvel.jpeg");
Ekran.drawImage(Cetvel, CetvelBaslangic, 10, CetvelBoyu, 138, this);
}
}
Yorumunuzu Ekleyin