Reputation: 21
is it possible, to disable Ctrl+V shortcut in my JavaFx application ? its like in the textfields, user will not be able to copy text from somewhere and paste it using Ctrl+V.
here's my controller class :
package application;
import com.jfoenix.controls.JFXTextField;
import javafx.fxml.FXML;
public class Controller {
@FXML
private JFXTextField t1 = new JFXTextField() {
@Override
public void paste() {
//do something to stop paste
}
};
}
Upvotes: 0
Views: 2079
Reputation: 674
You can do so by overriding the paste method and remove the line
super.paste();
it will do nothing when user try to paste
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args){
launch(args);
}
@Override
public void start(Stage stage){
TextField textField = new TextField(){
@Override
public void paste() {
}
};
Scene scene = new Scene(new StackPane(textField));
stage.setScene(scene);
stage.show();
}
}
Upvotes: 1