开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜