package org.dendy.app;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
public class CreateTE {
static Shell shell;
static StyledText text;
static LineStyleListener listener;
static Menu menu;
static Font font;
public static void main(String[] args) {
// menampilkan display
Display display = new Display();
shell = new Shell(display);
shell.setText("WINDOWS");
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
shell.setLayout(gridLayout);
// membuat text editor
text = new StyledText(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
text.setLayoutData(gridData);
// membuat menu bar
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
// membuat menu item
MenuItem item = new MenuItem(bar, SWT.CASCADE);
item.setText("View");
item.setAccelerator(SWT.MOD1 + 'X');
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
shell.update();
}
});
// Membuat toolbar
ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.HORIZONTAL);
ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
toolItem.setToolTipText("New");
toolItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
shell.update();
}
});
// membuat tampilan awal yang kita set sendiri
shell.setSize(400, 200);
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
}