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 |
Tags
- 그녀가말했다
- EV-DO Rev. B
- 김장훈의who
- ETF
- 공정위
- Wibro
- HSDPA
- 차트쇼쇼쇼
- 민동현
- 김장훈
- "명탐정 코난"
- 민동현의토요명화
- VoIP
- 위피
- brew
- 유희열의라디오천국
- 퀄컴
- 사요
- 러시아
- SWT
- 한국의 기획자들
- 라디오
- 이지형
- itmusic
- Java
- CDMA
- 자바
- 모던음악만만세
- 페이스북
- USIM
Archives
- Today
- Total
11-16 00:00
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