[컴][웹] GWT code snippet

google web toolkit code / gwt example


GWT code snippet




// .html file
<div id="keycodeTest"></div>


// keycode input
public void onModuleLoad() {
 buildKeycodePrintInput();
 
}

private void buildKeycodePrintInput() {


    FlowPanel container = new FlowPanel();

    container.add(new Label("namh input:"));
    final TextBox inputBox = new TextBox();
    container.add(inputBox);

    final HTMLPanel resultBox = new HTMLPanel("result");

    inputBox.setFocus(true);

    final RootPanel contentSlot = RootPanel.get("keycodeTest");
    if (contentSlot!=null){
        contentSlot.add(container);
        contentSlot.add(resultBox);
    }


    inputBox.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {

            Character a = (char)event.getNativeKeyCode();
            resultBox.add(new HTML(a.toString()));
        }
    });


}


작성중 ...





댓글 없음:

댓글 쓰기