Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TelaAcessorio extends javax.swing.JFrame {
- /**
- * Creates new form TelaAcessorio
- */
- public TelaAcessorio() {
- initComponents();
- // desativar botoes
- jBAntes.setEnabled(false);
- jBNext.setEnabled(false);
- }
- //intanciação
- Acessorio aces = new Acessorio();
- // vetor acessorio
- Acessorio[] vet = new Acessorio[5];
- int i =0;
- private void jBGravarActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- // verifica
- if(i<=4){
- aces.setCodigo(jTCod.getText());
- aces.setDesc(jTDesc.getText());
- aces.setPreco(jTPreco.getText());
- //add obj no vetor
- vet[i]=aces;
- i++;
- limpar();
- }
- else{
- jBNext.setEnabled(true);
- jTCod.setEditable(false);
- jTDesc.setEditable(false);
- jTPreco.setEditable(false);
- jBGravar.setEnabled(false);
- i=0;
- }
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- TelaPrincipal tela = new TelaPrincipal();
- tela.setVisible(true);
- this.dispose();
- }
- private void jBNextActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- // if(i==1){
- // jBNext.setEnabled(true);
- //}
- aces = vet[i];
- jTCod.setText(aces.getCodigo());
- jTDesc.setText(aces.getDesc());
- jTPreco.setText(aces.getPreco());
- i++;
- if(i==5){
- i=4;
- }
- }
- private void jBAntesActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- if(i==3){
- jBAntes.setEnabled(true);
- }
- aces = vet[i];
- jTCod.setText(aces.getCodigo());
- jTDesc.setText(aces.getDesc());
- jTPreco.setText(aces.getPreco());
- i--;
- if(i==0){
- jBAntes.setEnabled(false);
- }
- }
- private void limpar(){
- //limpar
- jTCod.setText(null);
- jTDesc.setText(null);
- jTPreco.setText(null);
- // foco
- jTCod.requestFocus();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement