开发者

Select all (CTRL+A) option not present in SWT Text field

开发者 https://www.devze.com 2022-12-21 02:52 出处:网络
I am using an SWT application. I can\'t select all text in a text box or text area by Ctrl+A. Is there any way to achie开发者_如何学JAVAve this?text.addKeyListener(new KeyAdapter() {

I am using an SWT application. I can't select all text in a text box or text area by Ctrl+A.

Is there any way to achie开发者_如何学JAVAve this?


text.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e)
    {
        if (e.stateMask == SWT.CTRL && e.keyCode == 'a') {
            text.selectAll();
            e.doit = false;
        }
    }
});


http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Addaselectallmenuitemtothecontrol.htm


Ideally as per LAF doco, if you have set the correct look and feel you should get this automatically.

UIManager.setLookAndFeel(
            UIManager.getCrossPlatformLookAndFeelClassName());

If not see what they have done here http://www.roseindia.net/java/example/java/swing/copy-data-from-ms.shtml

0

精彩评论

暂无评论...
验证码 换一张
取 消