Beruflich Dokumente
Kultur Dokumente
java.sql.Connection;
java.sql.DriverManager;
java.sql.SQLException;
java.sql.Statement;
javax.swing.JOptionPane;
/**
*
* @author Marcela
*/
public class guiEquipamento extends javax.swing.JFrame {
/**
* Creates new form guiEquipamento
*/
public guiEquipamento() {
initComponents();
}
/**
* 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">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
txtequipamento = new javax.swing.JTextField();
txtempresa = new javax.swing.JTextField();
txtsetor = new javax.swing.JTextField();
txtmanutencao = new javax.swing.JTextField();
txtmaterial = new javax.swing.JTextField();
btnincluir = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jLabel7 = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
jButton1.setText("jButton1");
jButton2.setText("jButton2");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel2.setText("Equipamento");
jLabel3.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel3.setText("Empresa");
jLabel4.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel4.setText("Setor");
jLabel5.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel5.setText("Manutencao");
jLabel6.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel6.setText("Material");
btnincluir.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
btnincluir.setText("Incluir");
btnincluir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnincluirActionPerformed(evt);
}
});
jScrollPane1.setViewportView(jList1);
jLabel7.setFont(new java.awt.Font("Monotype Corsiva", 3, 18)); // NOI18N
jLabel7.setText("Ficha de Cadastro de Equipamentos");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentP
ane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel4)
.addComponent(jLabel3)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(txtequipamento)
.addGroup(layout.createSequentialGroup()
.addComponent(txtempresa)
.addGap(5, 5, 5))
.addComponent(txtsetor)
.addComponent(txtmanutencao)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addComponent(jLabel7)
.addGroup(layout.createSequentialGroup()
.addComponent(txtmaterial, javax.swing.GroupLayo
ut.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnincluir)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SI
ZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(18, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 3
3, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(txtequipamento, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRE
D_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jLabel3)
.addComponent(txtempresa, javax.swing.GroupLayout.PREFERRED_
SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SI
ZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jLabel4)
.addComponent(txtsetor, javax.swing.GroupLayout.PREFERRED_SI
ZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE
))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jLabel5)
.addComponent(txtmanutencao, javax.swing.GroupLayout.PREFERR
ED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED
_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtmaterial, javax.swing.GroupLayout.PREFERRED
_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_S
IZE)
.addComponent(btnincluir))
.addGap(14, 14, 14)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SI
ZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(48, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void btnincluirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String url = "jdbc:postgresql://localhost:5432/dbaula1";
try{
Class.forName("org.postgresql.Driver");
} catch (java.lang.ClassNotFoundException e){
JOptionPane.showMessageDialog (null, "Classe de banco no encontrad
a");
}
Connection db = null;
try{
db = DriverManager.getConnection(url, "postgres", "postgres");
} catch (SQLException ex) {
JOptionPane.showMessageDialog (null, "Nao foi possivel conectar ao b
anco ");
}
String
String
String
String
String
equipamento = txtequipamento.getText();
empresa = txtempresa.getText();
setor = txtsetor.getText();
manutencao = txtmanutencao.getText();
material = txtmaterial.getText();