import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.*;
public class SWTExample{
public static void main(String[] args){
Display display = new Display();
Shell shell = new Shell(display);
shell.pack();
// shell.setLayout(new GridLayout());
shell.setSize(450, 400);
shell.setText("This is a window using SWT");
final Button button = new Button(shell,SWT.BUTTON1);
button.pack();
button.setSize(100,30);
button.setText("눌러봐");
final Button closebutton = new Button(shell,SWT.BUTTON1);
closebutton.pack();
closebutton.setSize(100,30);
closebutton.setLocation(110, 0);
closebutton.setText("창닫어");
Listener listener = new Listener(){
public void handleEvent(Event event){
if(event.widget == button){
System.out.println("눌렀네");
}else if(event.widget == closebutton){
System.out.println("닫어");
}
}
};
button.addListener(SWT.Selection,listener);
closebutton.addListener(SWT.Selection, listener);
shell.open();
while(!shell.isDisposed())
if(!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
'Programing > Java' 카테고리의 다른 글
윈도우 Java환경 설정 (0) | 2006.12.23 |
---|---|
에디트플러스 자바 컴파일/실행 설정 (0) | 2006.10.16 |
SWT 연습 - FileTreeContentProvider (0) | 2006.10.13 |
SWT Study (0) | 2006.10.13 |
적당한 크기로 만들어주는 메서드 - Control.pack() (4) | 2006.10.13 |