Social Icons

Cara mendapatkan bitcoin gratis

Sunday, 7 September 2014

membuat JSlider sederhana


Gan sekarang ini saya ingin membuat JSlider Sederhana, jangan panjang" lgi gan bahas nya dan lansung kita buka ajj notped ++ dan Copas kan coding dibawah  ini :

Souce Code :

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;



public class SimpleSliderDemo extends JFrame {

private JSlider slider;

private JTextField txtValue;



public SimpleSliderDemo() {

super ("JSlider Sederhana");



Container container = getContentPane();

container.setLayout(new FlowLayout());



txtValue = new JTextField (20);

txtValue.setBackground(Color.WHITE);

txtValue.setEditable(false);



slider = new JSlider(SwingConstants.HORIZONTAL,0,100,50);

txtValue.setText(String.valueOf(slider.getValue()));

slider.setMinorTickSpacing(5);

slider.setMajorTickSpacing(20);

slider.setPaintTicks(true);

slider.setLabelTable(slider.getLabelTable());

slider.setPaintLabels(true);



slider.addChangeListener (

new ChangeListener() {

public void stateChanged (ChangeEvent e) {

txtValue.setText ( String.valueOf(slider.getValue()) );

}

}

);



container.add(txtValue);

container.add(slider);



setSize (280,200);

setVisible (true);

}



public static void main (String args[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

SimpleSliderDemo test = new SimpleSliderDemo();

test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

maka outputnya seperti ini gan :
jangan lupa komentarnya ya gannn,,,,,,,
Salam Sukses gannn,,,,

No comments:

Post a Comment

jago Photoshop