private void enableFields(boolean b) { Titulo_Principal.setEditable(b); Titulo_Principal.setEnabled(b); Titulo_Secundario.setEditable(b); Titulo_Secundario.setEnabled(b); Descripcion.setEditable(b); Descripcion.setEnabled(b); Editorial.setEditable(b); Editorial.setEnabled(b); Fecha_Publicacion.setEditable(b); Fecha_Publicacion.setEnabled(b); Derechos_Autor.setEditable(b); Derechos_Autor.setEnabled(b); Idioma.setEnabled(b); Editar.setEnabled(!b); }
private boolean checkEmptyFields() { if (Titulo_Principal.getText() == null || Titulo_Principal.getText().equals("")) { JOptionPane.showMessageDialog( this, "El campo Titulo Principal no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (Titulo_Secundario.getText() == null || Titulo_Secundario.getText().equals("")) { JOptionPane.showMessageDialog( this, "El campo Titulo Secundario no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (Descripcion.getText() == null || Descripcion.getText().equals("")) { JOptionPane.showMessageDialog( this, "El campo Descripcion no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (Editorial.getText() == null || Editorial.getText().equals("")) { JOptionPane.showMessageDialog( this, "El campo Editorial no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (Fecha_Publicacion.getText() == null || Fecha_Publicacion.getText().equals("") || Fecha_Publicacion.getText().equals("YYYYMMDD")) { JOptionPane.showMessageDialog( this, "El campo Fecha Publicacion no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else if (Derechos_Autor.getText() == null || Derechos_Autor.getText().equals("")) { JOptionPane.showMessageDialog( this, "El campo Derechos de Autor no puede estar vacio", "Error", JOptionPane.ERROR_MESSAGE); return false; } else return true; }
private void guardarDatos() { documento.setTituloPrincipal(Titulo_Principal.getText()); documento.setTituloSecundario(Titulo_Secundario.getText()); documento.setDescripcion(Descripcion.getText()); documento.setEditorial(Editorial.getText()); documento.setFechaPublicacion(Fecha_Publicacion.getText()); documento.setDerechosAutor(Derechos_Autor.getText()); System.out.println(Idioma.getItemAt(Idioma.getSelectedIndex())); documento.setIdioma((String) Idioma.getItemAt(Idioma.getSelectedIndex())); Estado.setForeground(Color.green); Estado.setText("[Guardado]"); enableFields(false); biblioteca.gui.GUICatalogacion.Informacion_Basica_Guardada = true; }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); Titulo_Principal = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); Titulo_Secundario = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); Descripcion = new javax.swing.JTextArea(); jLabel6 = new javax.swing.JLabel(); Idioma = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); Editorial = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); Fecha_Publicacion = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); Derechos_Autor = new javax.swing.JTextField(); Estado = new javax.swing.JLabel(); Siguiente = new javax.swing.JButton(); Editar = new javax.swing.JButton(); jLabel1.setText("Titulo Principal: "); Titulo_Principal.setPreferredSize(new java.awt.Dimension(200, 28)); jLabel2.setText("Titulo Secundario: "); Titulo_Secundario.setPreferredSize(new java.awt.Dimension(200, 28)); jLabel3.setIcon( new javax.swing.ImageIcon( getClass().getResource("/biblioteca/gui/resources/logo.png"))); // NOI18N jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 24)); jLabel4.setText("Información Basica"); jLabel5.setText("Descripción:"); Descripcion.setColumns(20); Descripcion.setRows(5); Descripcion.setMargin(new java.awt.Insets(5, 5, 5, 5)); jScrollPane1.setViewportView(Descripcion); jLabel6.setText("Idioma:"); Idioma.setModel( new javax.swing.DefaultComboBoxModel( new String[] {"Inglés", "Español", "Portuges", "Otro"})); jLabel7.setText("Editorial: "); jLabel8.setText("Fecha Publicación: "); Fecha_Publicacion.setText("YYYYMMDD"); jLabel9.setText("Derechos de Autor: "); Estado.setFont(new java.awt.Font("Ubuntu", 0, 24)); // NOI18N Estado.setForeground(new java.awt.Color(255, 0, 0)); Estado.setText("[Sin Guardar]"); Siguiente.setFont(new java.awt.Font("Ubuntu", 1, 15)); Siguiente.setText("Siguiente Paso"); Siguiente.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SiguienteActionPerformed(evt); } }); Editar.setText("Editar"); Editar.setEnabled(false); Editar.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditarActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(22, 22, 22) .addComponent(jLabel1) .addGap(22, 22, 22) .addComponent( Titulo_Principal, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(12, 12, 12) .addComponent(jLabel2) .addGap(13, 13, 13) .addComponent( Titulo_Secundario, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(33, 33, 33) .addComponent(jLabel5) .addGap(34, 34, 34) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(44, 44, 44) .addComponent(jLabel7) .addGap(45, 45, 45) .addComponent( Editorial, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(11, 11, 11) .addComponent(jLabel8) .addGap(11, 11, 11) .addComponent( Fecha_Publicacion, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(52, 52, 52) .addComponent(jLabel6) .addGap(102, 102, 102) .addComponent( Idioma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGap(7, 7, 7) .addComponent(jLabel9) .addGap(8, 8, 8) .addComponent( Derechos_Autor, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addComponent(jLabel3) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE) .addComponent(jLabel4)) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addContainerGap() .addComponent(Estado) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 317, Short.MAX_VALUE) .addComponent(Siguiente) .addContainerGap()) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addContainerGap(538, Short.MAX_VALUE) .addComponent(Editar) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jLabel4)) .addGap(32, 32, 32) .addComponent(Editar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel1)) .addComponent( Titulo_Principal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel2)) .addComponent( Titulo_Secundario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(42, 42, 42) .addComponent(jLabel5)) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel7)) .addComponent( Editorial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel8)) .addComponent( Fecha_Publicacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel9)) .addComponent( Derechos_Autor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 10, 10) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(5, 5, 5) .addComponent(jLabel6)) .addComponent( Idioma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Siguiente) .addComponent(Estado)) .addContainerGap())); } // </editor-fold>//GEN-END:initComponents