@Override public Object getValueAt(int rowIndex, int columnIndex) { Aluno titulo = lista.get(rowIndex); switch (columnIndex) { case 0: return titulo.getId(); case 1: return titulo.getNome(); case 2: return titulo.getNota(); default: throw new IndexOutOfBoundsException("column index out of bounds"); } }
public ModificarAluno(Aluno aluno) { this.aluno = aluno; this.preencherComboBox(); this.layout.add(lblNome, 0, 0); this.layout.add(txtNome, 1, 0, 4, 1); this.txtNome.setText(aluno.getNome()); this.layout.add(lblResponsavel, 0, 1); this.layout.add(txtResponsavel, 1, 1); this.layout.add(btnProcurarResponsavel, 2, 1); try { // As vezes o responsável pode estar vazio, portanto não há nome para ser preenchido! this.txtResponsavel.setText(aluno.getResponsavel().getNome()); } catch (Exception erro) { // Não precisa de tratamento! } this.txtResponsavel.setEditable(false); this.btnProcurarResponsavel.setOnMouseClicked(this); this.layout.add(lblEndereco, 0, 2); this.layout.add(txtEndereco, 1, 2); this.txtEndereco.setText(aluno.getNomeLogradouro()); this.layout.add(lblNumero, 2, 2); this.layout.add(txtNumero, 3, 2); this.txtNumero.setText(aluno.getNumLogradouro()); this.layout.add(lblComplemento, 0, 3); this.layout.add(txtComplemento, 1, 3); this.txtComplemento.setText(aluno.getComplemento()); this.layout.add(lblBairro, 2, 3); this.layout.add(txtBairro, 3, 3); this.txtBairro.setText(aluno.getBairro()); this.layout.add(lblCidade, 0, 4); this.layout.add(txtCidade, 1, 4); this.txtCidade.setText(aluno.getCidade()); this.layout.add(lblCep, 2, 4); this.layout.add(txtCep, 3, 4); this.txtCep.setText(aluno.getCep()); this.layout.add(lblTelefone, 0, 5); this.layout.add(txtTelefone, 1, 5); this.txtTelefone.setText(aluno.getTelefone()); this.layout.add(lblCelular, 2, 5); this.layout.add(txtCelular, 3, 5); this.txtCelular.setText(aluno.getCelular()); this.layout.add(lblEmail, 0, 6); this.layout.add(txtEmail, 1, 6); this.txtEmail.setText(aluno.getEmail()); this.layout.add(lblDataNascimento, 2, 6); this.layout.add(containerDataNascimento, 3, 6); this.layout.add(new Label("* Campos Obrigatórios"), 0, 7); this.layout.add(btnModificar, 0, 8); this.layout.setVgap(15); this.layout.setHgap(15); this.txtCep.setMask("NNNNNNNN"); this.txtTelefone.setMask("NNNNNNNNNN"); this.txtCelular.setMask("NNNNNNNNNNN"); this.txtNumero.setMask("NNNNNNNNNNNNN"); this.btnModificar.setOnMouseClicked(this); this.btnProcurarResponsavel.setOnMouseClicked(this); this.setScene(cenaPrincipal); this.setTitle("Modificação de Aluno"); this.setResizable(false); this.getIcons() .add( new Image( Icones.getCaminhoIconePrincipal())); // Adiciona um ícone ao palco (Estrutura de // janela) this.layout.getStylesheets().add(FolhasEstilo.getCaminhoStyleDialogo()); this.layout.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { acionarBotaoModificar(); } else if (event.getCode() == KeyCode.ESCAPE) { close(); } } }); this.responsavel = aluno.getResponsavel(); // Por padrão o Responsável é o mesmo já selecionado no cadastro this.cmbAno.setPromptText("Ano"); this.cmbDia.setPromptText("Dia"); this.cmbMes.setPromptText("Mês"); if (this.aluno.getDataNascimento().isEmpty() == false) { this.cmbDia.getSelectionModel().select(this.aluno.getDataNascimento().substring(0, 2)); this.cmbMes .getSelectionModel() .select(Integer.parseInt(this.aluno.getDataNascimento().substring(3, 5)) - 1); this.cmbAno.getSelectionModel().select(this.aluno.getDataNascimento().substring(6, 10)); } }