Samples > いろいろなスタイルのボタン |
|
いろいろなスタイルのボタンButtonのコンストラクタに与えるスタイルの引数を組み合わせることで、いろいろなタイプのボタンを生成することができます。以下の例では、5 x 3 の15種類のボタンの組み合わせを表示しています。サンプルプログラムでは、JFaceのApplicationWindowを使っているので、実行するにはJFaceの設定をしておく必要があります。スクリーンショットソースコード (ButtonTest.java)import org.eclipse.swt.widgets.*; import org.eclipse.jface.window.*; import org.eclipse.swt.*; import org.eclipse.swt.layout.*; public class ButtonTest extends ApplicationWindow{ public ButtonTest() { super(null); } public static void main(String[] args) { ApplicationWindow w = new ButtonTest(); w.setBlockOnOpen(true); w.open(); Display.getCurrent().dispose(); } protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NULL); this.getShell().setText("ButtonTest"); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 4; layout.verticalSpacing = 9; Label label; label = new Label(container, SWT.NONE); label.setText("Button Type"); label = new Label(container, SWT.NONE); label.setText("NONE"); label = new Label(container, SWT.NONE); label.setText("BORDER"); label = new Label(container, SWT.NONE); label.setText("FLAT"); createLabel(container, SWT.NONE, "Push"); createButton(container, SWT.PUSH, "button1"); createButton(container, SWT.BORDER, "button2"); createButton(container, SWT.FLAT, "button3"); createLabel(container, SWT.NONE, "Radio"); createButton(container, SWT.RADIO, "button1"); createButton(container, SWT.RADIO | SWT.BORDER, "button2"); createButton(container, SWT.RADIO | SWT.FLAT, "button3"); createLabel(container, SWT.NONE, "Toggle"); createButton(container, SWT.TOGGLE, "button1"); createButton(container, SWT.TOGGLE | SWT.BORDER, "button2"); createButton(container, SWT.TOGGLE | SWT.FLAT, "button3"); createLabel(container, SWT.NONE, "Check"); createButton(container, SWT.CHECK, "button1"); createButton(container, SWT.CHECK | SWT.BORDER, "button2"); createButton(container, SWT.CHECK | SWT.FLAT, "button3"); createLabel(container, SWT.NONE, "Arrow | Left"); createButton(container, SWT.ARROW | SWT.LEFT, "button1"); createButton(container, SWT.ARROW | SWT.LEFT | SWT.BORDER, "button2"); createButton(container, SWT.ARROW | SWT.LEFT | SWT.FLAT, "button3"); return container; } public void createButton(Composite c, int style, String text){ Button b = new Button(c, style); b.setText(text); } public void createLabel(Composite c, int style, String text){ Label l = new Label(c, style); l.setText(text); } } 最新更新日: 2004年8月8日 |
- PR -
マイクロソフト お得な見積! まとめての購入ならオトクな方法で。ライセンスだから管理も簡単。 シマンテック 割引価格! オンライン販売だから低価格。いつでも簡単、見積・購入。 |
||||
|
|||||
Copyright(C) 2003,2004 Jasmin Project. All Right Reserved. |
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||