Eventos de ScrollBar
Hola,
Stoy haciendo una aplicacion que tiene dos scrollbar uno a la derecha y otro abajo.
mi pregunta es k evento tengo k usary como se cuando se me mueve una u otra
Stoy haciendo una aplicacion que tiene dos scrollbar uno a la derecha y otro abajo.
mi pregunta es k evento tengo k usary como se cuando se me mueve una u otra
ahi te va como se hace
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyApp extends Frame
{
JTextField caja=new JTextField("0");
Scrollbar s=new Scrollbar();
Scrollbar s2=new Scrollbar();
public MyApp()
{
this.addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
this.setTitle("Diego");
this.add("North",caja);
this.add("South",s);
this.add("Center",s2);
}
public boolean handleEvent( Event evt ) {
if( evt.target instanceof Scrollbar )
{
if (evt.target.equals(s))
System.out.println("mueve s");
else
System.out.println("mueve s2");
caja.setText( Integer.toString( ((Scrollbar)evt.target).getValue() ) );
return true;
}
return super.handleEvent( evt );
}
public static void main(String args[])
{
System.out.println("Starting App");
MyApp f = new MyApp();
f.setSize(200,200);
f.show();
}
}
y sale para pintura ojala te sirva
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyApp extends Frame
{
JTextField caja=new JTextField("0");
Scrollbar s=new Scrollbar();
Scrollbar s2=new Scrollbar();
public MyApp()
{
this.addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
this.setTitle("Diego");
this.add("North",caja);
this.add("South",s);
this.add("Center",s2);
}
public boolean handleEvent( Event evt ) {
if( evt.target instanceof Scrollbar )
{
if (evt.target.equals(s))
System.out.println("mueve s");
else
System.out.println("mueve s2");
caja.setText( Integer.toString( ((Scrollbar)evt.target).getValue() ) );
return true;
}
return super.handleEvent( evt );
}
public static void main(String args[])
{
System.out.println("Starting App");
MyApp f = new MyApp();
f.setSize(200,200);
f.show();
}
}
y sale para pintura ojala te sirva
