Bom, eu fiz uma tela para cadastro de clientes, tanto físicos quanto jurídicos, o meu (grande) problema é que quando o usuário selecionar “Pessoa Juridica” eu fiz com o jLabel trocasse o nome “CPF” para “CNPJ”, o ComboBox “Sexo” e o TextBox “Data de nascimento” sumissem.
Mas quando isso acontece toda a minha fica desconfigurada. Os Campos de texto vão pra direita e o que eu tenho logo abaixo acaba vindo pra cima.
Tem algum jeito de evitar isso?
Aqui vai um print da minha tela
akah
Março 22, 2013, 12:47pm
#2
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
public class Testes extends Shell {
private Label lblCpf;
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Testes shell = new Testes(display);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public Testes(Display display) {
super(display, SWT.SHELL_TRIM);
Button btnPf = new Button(this, SWT.RADIO);
btnPf.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
lblCpf.setText("CPF");
}
});
btnPf.setBounds(10, 10, 47, 16);
btnPf.setText("PF");
Button btnPj = new Button(this, SWT.RADIO);
btnPj.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
lblCpf.setText("CNPJ");
}
});
btnPj.setBounds(63, 10, 47, 16);
btnPj.setText("PJ");
lblCpf = new Label(this, SWT.NONE);
lblCpf.setBounds(10, 32, 55, 15);
lblCpf.setText("CPF");
createContents();
}
/**
* Create contents of the shell.
*/
protected void createContents() {
setText("SWT Application");
setSize(450, 300);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
Desculpa amigo, não entendi o porquê da sua resposta :?
Só sabendo como você montou a tela… mas eu teria ali nos campos que mudam um JPanel com CardLayout e, dentro dele, um painel para cada tipo de pessoa.