domingo, 31 de marzo de 2013

JScrollbar Programador Java Interfaz Gráfico GUI AWT Swing 1 Swing 2


 JScrollbar Programador Java Interfaz Gráfico GUI AWT Swing 1 Swing 2






import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;



public class jScrollbarss extends JFrame {

  private JLabel jLabel1 = new JLabel();
  private JLabel jLabel2 = new JLabel();
  private JScrollBar jScrollBar1 = new JScrollBar();

 
  public jScrollbarss(String title) {
 
    super(title);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 300;
    int frameHeight = 300;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2;
    setLocation(x, y);
    setResizable(false);
    Container cp = getContentPane();
    cp.setLayout(null);
   
   
    cp.setBackground(new Color(0x119BEE));
    jLabel1.setBounds(48, 32, 187, 65);
    jLabel1.setText("JScrollBar");
    jLabel1.setFont(new Font("Gunplay 3D", Font.BOLD, 36));
    jLabel1.setForeground(Color.YELLOW);
    cp.add(jLabel1);
    jLabel2.setBounds(48, 184, 195, 41);
    jLabel2.setText("");
    cp.add(jLabel2);
    jScrollBar1.setBounds(48, 120, 209, 33);
    jScrollBar1.setOrientation(Scrollbar.HORIZONTAL);
    cp.add(jScrollBar1);
 
    jScrollBar1.addAdjustmentListener(new AdjustmentListener() {
      public void adjustmentValueChanged (AdjustmentEvent evt) {
        jScrollbar1_AdjustmentValueChanged (evt);
      }
    });
   
    setVisible(true);
  }
 
  public void jScrollbar1_AdjustmentValueChanged(AdjustmentEvent evt) {
    jLabel2.setText("El valor es: "+jScrollBar1.getValue());
   
  }
 
  public static void main(String[] args) {
    new jScrollbarss("jScrollbarss");
  }
 
}



No hay comentarios:

Publicar un comentario