Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 러시아
- brew
- HSDPA
- 위피
- 민동현
- 라디오
- 김장훈
- 차트쇼쇼쇼
- 자바
- VoIP
- 이지형
- ETF
- "명탐정 코난"
- 김장훈의who
- 민동현의토요명화
- 모던음악만만세
- SWT
- Java
- 사요
- CDMA
- 그녀가말했다
- 페이스북
- 공정위
- 한국의 기획자들
- 유희열의라디오천국
- 퀄컴
- itmusic
- Wibro
- EV-DO Rev. B
- USIM
Archives
- Today
- Total
12-26 13:05
zyint's blog
SWT Table Simple Demo 본문
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
public class TableClass {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(280, 300);
shell.setText("Table Example");
final Text text = new Text(shell, SWT.BORDER);
text.setBounds(25, 240, 220, 25);
Table table = new Table(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL);
table.setHeaderVisible(true);
String[] titles = { "Col 1", "Col 2", "Col 3", "Col 4" };
for (int loopIndex = 0; loopIndex < titles.length; loopIndex++) {
TableColumn column = new TableColumn(table, SWT.NULL);
column.setText(titles[loopIndex]);
}
for (int loopIndex = 0; loopIndex < 24; loopIndex++) {
TableItem item = new TableItem(table, SWT.NULL);
item.setText("Item " + loopIndex);
item.setText(0, "Item " + loopIndex);
item.setText(1, "Yes");
item.setText(2, "No");
item.setText(3, "A table item");
}
for (int loopIndex = 0; loopIndex < titles.length; loopIndex++) {
table.getColumn(loopIndex).pack();
}
table.setBounds(25, 25, 220, 200);
table.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
text.setText("You checked " + event.item);
} else {
text.setText("You selected " + event.item);
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Comments