我有以下代码没有标记滑块“foo50”等...正如人们所期望的setLabelFormatter
调用,但似乎没有效果(滑块标记为50,100等等,而println不运行)。有什么我想念的吗?这是否未在默认的2.2皮肤中实现?使用Oracle Java 7
package javafxbugtest;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.*;
import javafx.util.StringConverter;
public class JavaFXBugTest extends Application
{
@Override
public void start(final Stage primaryStage)
{
Slider cp = new Slider();
cp.setLabelFormatter(new StringConverter<Double>() {
@Override
public String toString(Double t)
{
System.out.println("nope?");
return "foo" + t.toString();
}
@Override
public Double fromString(String string)
{
System.out.println("hey");
throw new UnsupportedOperationException("Not supported yet.");
}
});
cp.setMax(300);
cp.setMin(0);
cp.setShowTickLabels(true);
cp.setShowTickMarks(true);
cp.setMajorTickUnit(50);
cp.setMinorTickCount(4);
cp.setValue(152);
Scene scene = new Scene(cp);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}