<更新記録>
2007年 12月 12日
作成

姉妹サイト検索 Web検索


Button - ボタン

Button

Buttonクラスは、Controlクラスの子として定義されています。 Buttonクラスは、多分、ほとんどのアプリケーションで頻繁に使われる部品なのではないかと思います。 Buttonクラスは、スタイルの指定によって、 押下式ボタン、ラジオボタン、チェックボックス等として作成することが可能です。

サンプル

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class ButtonComposite extends Composite {
	public ButtonComposite(Composite parent) {
		super(parent, SWT.NONE);
		
		int y = 5;
		
		Button pushButton = new Button(this, SWT.PUSH);
		pushButton.setText("ボタン");
		pushButton.setLocation(5, y);
		pushButton.pack();
		
		Button toggleButton = new Button(this, SWT.TOGGLE);
		toggleButton.setText("トグルボタン");
		toggleButton.setLocation(5, y += 30);
		toggleButton.pack();
		
		Button checkButton = new Button(this, SWT.CHECK);
		checkButton.setText("チェックボックス");
		checkButton.setLocation(5, y += 30);
		checkButton.pack();
		
		Button checkButton2 = new Button(this, SWT.CHECK);
		checkButton2.setText("チェックボックス2");
		checkButton2.setLocation(5, y += 30);
		checkButton2.setSelection(true);
		checkButton2.pack();
		
		Button radioButton = new Button(this, SWT.RADIO);
		radioButton.setText("ラジオボタン");
		radioButton.setLocation(5, y += 30);
		radioButton.pack();
		
		Button radioButton2 = new Button(this, SWT.RADIO);
		radioButton2.setText("ラジオボタン2");
		radioButton2.setLocation(5, y += 30);
		radioButton2.setSelection(true);
		radioButton2.pack();
		
		pack();
	}
}

ボタンが押された時に何か動作を行うには、eventを理解する必要があります。


Powered by VeryEasyCMS