javafx.scene.AccessibleRole Java Examples

The following examples show how to use javafx.scene.AccessibleRole. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChoosePane.java    From oim-fx with MIT License 6 votes vote down vote up
private void initialize() {
	getStyleClass().setAll(DEFAULT_STYLE_CLASS);
	setAccessibleRole(AccessibleRole.TOGGLE_BUTTON);
	// alignment is styleable through css. Calling setAlignment
	// makes it look to css like the user set the value and css will not
	// override. Initializing alignment by calling set on the
	// CssMetaData ensures that css will be able to override the value.
	((StyleableProperty<Pos>) (WritableValue<Pos>) alignmentProperty()).applyStyle(null, Pos.CENTER);

	this.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {

		@Override
		public void handle(MouseEvent event) {
			doSelected();
		}
	});
}
 
Example #2
Source File: JFXTimePicker.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
private void initialize() {
    getStyleClass().add(DEFAULT_STYLE_CLASS);
    setAccessibleRole(AccessibleRole.DATE_PICKER);
    setEditable(true);
}
 
Example #3
Source File: StyledTextField.java    From RichTextFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public StyledTextField(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
        @NamedArg("applyParagraphStyle")   BiConsumer<TextFlow, PS> applyParagraphStyle,
        @NamedArg("initialTextStyle")      S initialTextStyle,
        @NamedArg("applyStyle")            BiConsumer<? super TextExt, S> applyStyle,
        @NamedArg("document")              EditableStyledDocument<PS, String, S> document)
{
    super( initialParagraphStyle, applyParagraphStyle, initialTextStyle, applyStyle, document, true );

    getStylesheets().add( STYLE_SHEET );
    getStyleClass().setAll( "styled-text-field" );

    setAccessibleRole( AccessibleRole.TEXT_FIELD );
    setPrefSize( 135, HEIGHT );

    addEventFilter( KeyEvent.KEY_PRESSED, KE -> {
        if ( KE.getCode() == KeyCode.ENTER ) {
            fireEvent( new ActionEvent( this, null ) );
            KE.consume();
        }
        else if ( KE.getCode() == KeyCode.TAB ) {
            traverse( this.getParent(), this, KE.isShiftDown() ? -1 : +1 );
            KE.consume();
        }
    });

    addEventFilter( MouseEvent.MOUSE_PRESSED, ME -> selectAll = isFocused() );

    focusedProperty().addListener( (ob,was,focused) -> {
        if ( ! was && focused && selectAll ) {
            selectRange( getLength(), 0 );
        }
        else if ( ! focused && was ) {
            moveTo( 0 ); requestFollowCaret();
        }
        selectAll = true;
    });

    super.setWrapText( false );
    wrapTextProperty().addListener( (ob,ov,wrap) -> {
        if ( wrap ) { // veto any changes
            wrapTextProperty().unbind();
            super.setWrapText(false);
        }
    });
}