-
Bug
-
Resolution: Duplicate
-
P4
-
fx2.0
-
(JavaFX 2.0 beta b30 & b32 + JDK 1.6.0_25 + WinXP SP3)
Can not show or hide Slider's tick label or tick mark independently
(JavaFX 2.0 beta b30 & b32 + JDK 1.6.0_25 + WinXP SP3)
Can not show or hide Slider's tick label or tick mark independently using
Slider.setShowTickLabels(true/false) and Slider.setShowTickMarks(true/false).
Tick label and tick mark always show up or be hidden at the same time, that
is, calling Slider.setShowTickLabels(false) won't hide the tick label if at
some time before Slider.setShowTickMarks(true) was called - in this case, one
has to call Slider.setShowTickMarks(false), but this will hide both the tick
labels and the tick marks. It seems Slider.setShowTickMarks(...) and
Slider.setShowTickLabels(...) have unnecessary dependency.
Below codes for re-reproducing...
1. If you click <Hide Tick Labels>, nothing happens, then,
2. If you click <Hide Tick Marks>, both the tick labels and tick marks disappear
3. If you click <Show Tick Labels>, nothing happens, then,
3. If you click <Show Tick Marks>, both the tick labels and tick marks show up
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.stage.Stage;
/**
*
* @author lianqi.li
*/
public class SliderIssue extends Application {
@Override public void start(Stage stage) {
final Group root = new Group();
final Scene scene = new Scene(root, 400, 300);
final Slider slider = new Slider(1, 10, 1);
slider.setBlockIncrement(1.0d);
slider.setShowTickMarks(true);
slider.setShowTickLabels(true);
slider.setMajorTickUnit(1);
slider.setLayoutX(20);
slider.setLayoutY(20);
final Button b1 = new Button("Show Tick Labels");
b1.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
slider.setShowTickLabels(true);
}
});
b1.setLayoutX(20);
b1.setLayoutY(100);
final Button b2 = new Button("Hide Tick Labels");
b1.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
slider.setShowTickLabels(false);
}
});
b2.setLayoutX(160);
b2.setLayoutY(100);
final Button b3 = new Button("Show Tick Marks");
b3.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
slider.setShowTickMarks(true);
}
});
b3.setLayoutX(20);
b3.setLayoutY(160);
final Button b4 = new Button("Hide Tick Marks");
b4.setOnAction(new EventHandler() {
@Override
public void handle(Event event) {
slider.setShowTickMarks(false);
}
});
b4.setLayoutX(160);
b4.setLayoutY(160);
root.getChildren().addAll(slider, b1, b2, b3, b4);
stage.setScene(scene);
stage.setVisible(true);
}
public static void main(String[] args) {
Application.launch(SliderIssue.class, args);
}
}