블로그 이미지
초딩입맛제주아재
하고 싶은 것만 하며 살고 싶다

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
2006. 10. 13. 21:54 Programing/Java

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();
}
}



posted by 초딩입맛제주아재