开发者

operator | for int value

开发者 https://www.devze.com 2023-04-02 16:43 出处:网络
I think this is a basic in java,but sorry, I ask in stackoverflow. I will give an example in eclipse RCP.For example, if I want to make instance of Text (swt text), I would do below:

I think this is a basic in java, but sorry, I ask in stackoverflow.

I will give an example in eclipse RCP. For example, if I want to make instance of Text (swt text), I would do below:

Text text = new Text(composite, SWT.BORDER | SWT.MULTI);

In second parameter Text, it is a int style, and I would the text will be border and can be multi line, so I add SWT.BORDER | SWT.MULTI (th开发者_如何学JAVAe operator | will be used).

Now the question, for example I add already have a variable int style by the method getStyle() in the Text class. But I want to check if the SWT.MULTI is already set or not, how can I archive it? Thanks


bool multiIsSet = (x & SWT.MULTI) == SWT.Multi


Your solution is the bitwise & operator.

if (myText.getStyle() & SWT.MULTI){
 //whatever
}
0

精彩评论

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