Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. public class TelaAcessorio extends javax.swing.JFrame {
  2.  
  3. /**
  4. * Creates new form TelaAcessorio
  5. */
  6. public TelaAcessorio() {
  7. initComponents();
  8. // desativar botoes
  9. jBAntes.setEnabled(false);
  10. jBNext.setEnabled(false);
  11.  
  12.  
  13. }
  14. //intanciação
  15. Acessorio aces = new Acessorio();
  16. // vetor acessorio
  17. Acessorio[] vet = new Acessorio[5];
  18. int i =0;
  19.  
  20.  
  21. private void jBGravarActionPerformed(java.awt.event.ActionEvent evt) {
  22. // TODO add your handling code here:
  23.  
  24. // verifica
  25. if(i<=4){
  26.  
  27. aces.setCodigo(jTCod.getText());
  28. aces.setDesc(jTDesc.getText());
  29. aces.setPreco(jTPreco.getText());
  30.  
  31. //add obj no vetor
  32. vet[i]=aces;
  33. i++;
  34. limpar();
  35.  
  36. }
  37.  
  38. else{
  39.  
  40. jBNext.setEnabled(true);
  41. jTCod.setEditable(false);
  42. jTDesc.setEditable(false);
  43. jTPreco.setEditable(false);
  44. jBGravar.setEnabled(false);
  45. i=0;
  46.  
  47. }
  48.  
  49. }
  50.  
  51. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  52. // TODO add your handling code here:
  53. TelaPrincipal tela = new TelaPrincipal();
  54. tela.setVisible(true);
  55. this.dispose();
  56. }
  57.  
  58. private void jBNextActionPerformed(java.awt.event.ActionEvent evt) {
  59. // TODO add your handling code here:
  60.  
  61. // if(i==1){
  62. // jBNext.setEnabled(true);
  63. //}
  64.  
  65.  
  66. aces = vet[i];
  67.  
  68. jTCod.setText(aces.getCodigo());
  69. jTDesc.setText(aces.getDesc());
  70. jTPreco.setText(aces.getPreco());
  71.  
  72. i++;
  73.  
  74. if(i==5){
  75. i=4;
  76. }
  77.  
  78. }
  79.  
  80. private void jBAntesActionPerformed(java.awt.event.ActionEvent evt) {
  81. // TODO add your handling code here:
  82.  
  83. if(i==3){
  84. jBAntes.setEnabled(true);
  85. }
  86.  
  87. aces = vet[i];
  88.  
  89. jTCod.setText(aces.getCodigo());
  90. jTDesc.setText(aces.getDesc());
  91. jTPreco.setText(aces.getPreco());
  92.  
  93. i--;
  94.  
  95. if(i==0){
  96. jBAntes.setEnabled(false);
  97.  
  98. }
  99.  
  100. }
  101.  
  102. private void limpar(){
  103. //limpar
  104. jTCod.setText(null);
  105. jTDesc.setText(null);
  106. jTPreco.setText(null);
  107. // foco
  108. jTCod.requestFocus();
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement