The Goal
Keep walking……
posts - 23,  comments - 1,  trackbacks - 0
  • SWT.PUSH

Button类的默认风格。
SWT.FLAT

  • SWT.ARROW

与SWT.UP, SWT.DOWN, SWT.LEFT, and SWT.RIGHT组合,也可使用SWT.FLAT

  • SWT.TOGGLE

类似于SWT.PUSH,但是按下后会保持按下状态。可通过setSelection(boolean)方法来改变其状态。接下去介绍的check按钮和radio按钮也share这个功能

  • SWT.CHECK

建议用数组来实现,如下:
Button[] checks = new Button[2];
checks[0] = new Button(shell, SWT.CHECK);
checks[0].setText("Choice 1");
checks[0].setLocation(10,5);
checks[0].pack();
checks[1] = new Button(shell, SWT.CHECK);
checks[1].setText("Choice 2");
checks[1].setLocation(10,30);
checks[1].pack();

  • SWT.RADIO

建议用数组来实现,如下:
Button[] radios = new Button[3];
radios[0] = new Button(shell, SWT.RADIO);
radios[0].setSelected(true);
radios[0].setText("Choice 1");
radios[0].setLocation(10,5);
radios[0].pack();
radios[1] = new Button(shell, SWT.RADIO);
radios[1].setText("Choice 2");
radios[1].setLocation(10,30);
radios[1].pack();
radios[2] = new Button(shell, SWT.RADIO);
radios[2].setText("Choice 3");
radios[2].setLocation(10,55);
radios[2].pack();
for (int i=0; i<radios.length; i++)
if (radios[i].getSelected())
System.out.println(i);


通过RadioGroupFieldEditors将radio buttons组合在一起:

RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor(
"UserChoice", "Choose an option:", 1,
new String[][] {{"Choice1", "ch1"},
{"Choice2", "ch2"},
{"Choice3", "ch3"}},
shell, true);

其中的各个参数含义如下——1.name for the type of value returned by the editor.2.group label.3.列数。4.creates a set of option names with their associated values.In this manner, the RadioGroupFieldEditor can display a series of radio buttons without allocating Button objects.5.将editor加至Shell对象。6.specifies whether the radio buttons should be incorporated in a Group object.

在SWT/JFace中,container widgets是由Composite类来提供的。

posted on 2006-03-21 17:03 JOO 阅读(272) 评论(0)  编辑  收藏 所属分类: SWT & JFace IN ACTION

只有注册用户登录后才能发表评论。


网站导航:
 
Hit the target!

<2006年3月>
2627281234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(2)

随笔分类(23)

随笔档案(22)

文章档案(1)

相册

Neighbor

搜索

  •  

最新评论

阅读排行榜

评论排行榜