| 1 | package com.itmill.toolkit.tests.tickets; |
|---|
| 2 | |
|---|
| 3 | import com.itmill.toolkit.Application; |
|---|
| 4 | import com.itmill.toolkit.ui.Button; |
|---|
| 5 | import com.itmill.toolkit.ui.GridLayout; |
|---|
| 6 | import com.itmill.toolkit.ui.Label; |
|---|
| 7 | import com.itmill.toolkit.ui.Window; |
|---|
| 8 | import com.itmill.toolkit.ui.Button.ClickEvent; |
|---|
| 9 | import com.itmill.toolkit.ui.Button.ClickListener; |
|---|
| 10 | |
|---|
| 11 | public class TicketButtonClickPosition extends Application implements ClickListener { |
|---|
| 12 | |
|---|
| 13 | public void init() { |
|---|
| 14 | Window w = new Window(getClass().getSimpleName()); |
|---|
| 15 | setMainWindow(w); |
|---|
| 16 | |
|---|
| 17 | GridLayout layout = new GridLayout(4, 3); |
|---|
| 18 | |
|---|
| 19 | for (int i = 0; i<10; i++) { |
|---|
| 20 | Button b = new Button("button "+i, this); |
|---|
| 21 | layout.addComponent(b); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | w.setLayout(layout); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | public void buttonClick(ClickEvent event) { |
|---|
| 28 | int x = event.getClientX(); |
|---|
| 29 | int y = event.getClientY(); |
|---|
| 30 | Window w = new Window(); |
|---|
| 31 | w.setWidth(100); |
|---|
| 32 | w.setHeight(50); |
|---|
| 33 | w.addComponent(new Label("x:"+x+" y:"+y)); |
|---|
| 34 | w.setPositionX(x); |
|---|
| 35 | w.setPositionY(y); |
|---|
| 36 | this.getMainWindow().addWindow(w); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | } |
|---|