我尝试了很多互联网上可用的东西,但是找不到合适的东西
..float value..
Immediately suggests a JSpinner
with an appropriate SpinnerNumberModel
to me. EG
import javax.swing.*;
public class FloatSpinner {
public static void main(String[] args) {
Runnable r = new Runnable() {
@Override
public void run() {
SpinnerNumberModel floatModel = new SpinnerNumberModel(
2.14f, 0f, 3f, .01f);
JSpinner spinner = new JSpinner(floatModel);
JOptionPane.showMessageDialog(null, spinner);
System.out.println(
"User Chose: " + floatModel.getNumber().floatValue());
}
};
SwingUtilities.invokeLater(r);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.