MouseKey 코드보기
import org.eclipse.swt.events.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.*; public class Ch4_MouseKey extends Composite{ Label output; public Ch4_MouseKey(Composite parent){ super(parent, SWT.NONE); Button typed = new Button(this, SWT.PUSH); typed.setText("Typed"); typed.setLocation(2, 10); typed.pack(); typed.addKeyListener(new KeyAdapter(){ public void keyPressed(KeyEvent e){ keyHandler(); } }); Button untyped = new Button(this, SWT.PUSH); untyped.setText("Untyped"); untyped.setLocation(80, 10); untyped.pack(); untyped.addListener(SWT.MouseEnter, UntypedListener); untyped.addListener(SWT.MouseExit, UntypedListener); output = new Label(this, SWT.SHADOW_OUT); output.setBounds(40, 70, 90, 40); output.setText("No Event"); this.pack(); } Listener UntypedListener = new Listener(){ public void handleEvent(Event event){ switch(event.type){ case SWT.MouseEnter: output.setText("Mouse Enter"); break; case SWT.MouseExit: output.setText("Mouse Exit"); break; } } }; void keyHandler(){ output.setText("Key Event"); } }
CompViewer코드보기
import org.eclipse.jface.window.*; import org.eclipse.swt.widgets.*; public class CompViewer extends ApplicationWindow { public CompViewer() { super(null); } protected Control createContents(Composite parent){ Ch4_MouseKey cc1 = new Ch4_MouseKey(parent); return parent; } public static void main(String[] args) { CompViewer cv = new CompViewer(); cv.setBlockOnOpen(true); cv.open(); Display.getCurrent().dispose(); } }
크리에이티브 커먼즈 라이선스
http://dynast.tistory.com/trackback/145