Created
October 5, 2010 18:54
-
-
Save eduardodaluz/612089 to your computer and use it in GitHub Desktop.
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.gui; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.layout.GridLayout; | |
import org.eclipse.swt.widgets.Display; | |
import org.eclipse.swt.widgets.Label; | |
import org.eclipse.swt.widgets.Shell; | |
import org.eclipse.swt.widgets.Text; | |
public class TestLayout { | |
private Shell shell = null; | |
private Label lbNome = null; | |
private Text txNome = null; | |
private Label lbEndereco = null; | |
private Text txEndereco = null; | |
public static void main(String args[]) { | |
Display display = Display.getDefault(); | |
TestLayout thisClass = new TestLayout(); | |
thisClass.createShell(); | |
thisClass.shell.open(); | |
while(!thisClass.shell.isDisposed()){ | |
if(!display.readAndDispatch()) | |
display.sleep(); | |
} | |
display.dispose(); | |
} | |
private void createShell() { | |
shell = new Shell(); | |
shell.setSize(400, 300); | |
shell.setText("Teste de GridLayout - www.bitMasters.com.br"); | |
//Aqui começa o uso do GridLayout, | |
//instancio o Objeto e defino que o meu shell | |
//tera duas colunas. | |
GridLayout grLayout = new GridLayout(); | |
grLayout.numColumns = 2; | |
//defino o Layout do Objeto shell como GridLayout | |
shell.setLayout(grLayout); | |
// Agora instancio a Label lbNome | |
// que recebe a posição linha 1, coluna 1 | |
lbNome = new Label(shell, SWT.NONE); | |
lbNome.setText("Nome:"); | |
// Agora instancio o Text txNome | |
// que recebe a posição linha 1, coluna 2 | |
txNome = new Text(shell, SWT.BORDER); | |
// Agora instancio a Label lbEndereco | |
// que recebe a posição linha 2, coluna 1 | |
lbEndereco = new Label(shell, SWT.NONE); | |
lbEndereco.setText("Endereço:"); | |
// Agora instancio o Text txEndereco | |
// que recebe a posição linha 2, coluna 2. | |
// E assim por diante, todo Objeto que instancio | |
// usando o contanier Shell e excede o limite de | |
// colunas passa para a proxima linha ex(3,1; 3,2; 4.1; ...). | |
txEndereco = new Text(shell, SWT.BORDER); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment