Created
November 6, 2010 17:39
-
-
Save eduardodaluz/665561 to your computer and use it in GitHub Desktop.
MyApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.bitmasters.swt; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.events.SelectionAdapter; | |
import org.eclipse.swt.events.SelectionEvent; | |
import org.eclipse.swt.layout.RowData; | |
import org.eclipse.swt.layout.RowLayout; | |
import org.eclipse.swt.widgets.Button; | |
import org.eclipse.swt.widgets.Display; | |
import org.eclipse.swt.widgets.Label; | |
import org.eclipse.swt.widgets.ProgressBar; | |
import org.eclipse.swt.widgets.Shell; | |
import org.eclipse.swt.widgets.Text; | |
public class MyApp { | |
private Shell shell; | |
private Label lbStatus; | |
private Text txStatus; | |
private ProgressBar pbStatus; | |
private Button btProcess; | |
private RowLayout rowLayout; | |
private RowData rowData; | |
public static void main(String[] args) { | |
Display display = Display.getDefault(); | |
MyApp thisClass = new MyApp(); | |
thisClass.createShell(); | |
thisClass.shell.open(); | |
while(!thisClass.shell.isDisposed()) { | |
if(!display.readAndDispatch()) | |
display.sleep(); | |
} | |
display.dispose(); | |
} | |
private void createShell() { | |
shell = new Shell(); | |
shell.setText("MyApp - bitMasters.com.br"); | |
shell.setSize(400, 150); | |
rowLayout = new RowLayout(3); | |
rowLayout.fill = true; | |
rowLayout.wrap = true; | |
shell.setLayout(rowLayout); | |
rowData = new RowData(); | |
rowData.width = 375; | |
lbStatus = new Label(shell, SWT.NONE); | |
lbStatus.setText("Status:"); | |
lbStatus.setLayoutData(rowData); | |
txStatus = new Text(shell, SWT.BORDER); | |
txStatus.setLayoutData(rowData); | |
txStatus.setText("Fui criado pela thread: " + Thread.currentThread().getName()); | |
pbStatus = new ProgressBar(shell, SWT.SMOOTH); | |
pbStatus.setLayoutData(rowData); | |
btProcess = new Button(shell, SWT.PUSH); | |
btProcess.setText("Processar"); | |
btProcess.addSelectionListener(new SelectionAdapter() { | |
@Override | |
public void widgetSelected(SelectionEvent e) { | |
MyThread myThread = new MyThread(txStatus, pbStatus); | |
new Thread(myThread).start(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment