1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class Seuillage extends JDialog {
private JTextField textField;
static final int FPS_MIN = 0;
static final int FPS_MAX = 255;
static final int FPS_INIT = 128;
int i;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
Seuillage dialog = new Seuillage();
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog
*/
public Seuillage() {
super();
setTitle("Seuillage");
setResizable(false);
getContentPane().setLayout(null);
setBounds(100, 100, 364, 199);
final JSlider seuil = new JSlider(JSlider.HORIZONTAL,FPS_MIN, FPS_MAX, FPS_INIT);
seuil.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent arg0) {
i= seuil.getValue();
String j = new String();
j = j.valueOf(i);
textField.setText(j);
}
});
seuil.setValue(128);
seuil.setMajorTickSpacing(50);
seuil.setMaximum(255);
seuil.setMinorTickSpacing(10);
seuil.setPaintTicks(true);
seuil.setPaintLabels(true);
seuil.setBounds(0, 56, 291, 58);
getContentPane().add(seuil);
textField = new JTextField();
String j = new String();
j = j.valueOf(seuil.getValue());
textField.setText(j);
textField.setBounds(297, 65, 57, 26);
final JButton okButton = new JButton();
okButton.setText("OK");
okButton.setBounds(109, 125, 74, 23);
seuil.add(okButton);
getContentPane().add(textField);
final JButton okButton_1 = new JButton();
okButton_1.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent arg0) {
}
});
okButton_1.setText("OK");
okButton_1.setBounds(114, 136, 76, 23);
getContentPane().add(okButton_1);
}
public int getseuil() {
return i;
}
} |
Partager