Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is the underscore in my CheckBox?

The shortest possible program to show my problem:

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class TestCheckBox extends Application  {

    public static void main(String[] args) {
        launch(args);
    }

    public void start(Stage stage) {
        Scene scene = new Scene(new StackPane());
        final VBox vbox = new VBox();
        vbox.getChildren().addAll(new Label("ABC_DEF"), new CheckBox("ABC_DEF"));
        ((StackPane) scene.getRoot()).getChildren().add(vbox);
        stage.setScene(scene);
        stage.show();
    }
}

leads to:

enter image description here

In SceneBuilder by comparison it´s displayed normally, but not in my application. I am running Java 1.8.0-b129

Any hint?

like image 486
1813222 Avatar asked Feb 27 '14 20:02

1813222


1 Answers

You probably want to setMnemonicParsing to false on the CheckBox.

MnemonicParsing property to enable/disable text parsing. If this is set to true, then the Label text will be parsed to see if it contains the mnemonic parsing character '_'. When a mnemonic is detected the key combination will be determined based on the succeeding character, and the mnemonic added.

The default value for Labeled is false, but it is enabled by default on some Controls.

like image 141
jewelsea Avatar answered Sep 23 '22 19:09

jewelsea