Ele da construído com sucesso, não aparece em qual linha foi o erro.
package visao;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import modeloConection.ConexaoBD;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.Timer;
import java.sql.Connection;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
public class TelaPrincipal extends javax.swing.JFrame {
ConexaoBD conecta = new ConexaoBD();
FormMedico tela = new FormMedico();
FormUsuario telaUsu = new FormUsuario();
Connection conexao = null;
public TelaPrincipal(String usuario) {
initComponents();
jLabelUsuario.setText(usuario);
conecta.conexao();
int flag = 0;
}
private TelaPrincipal() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabelUsuario = new javax.swing.JLabel();
jLabelHora = new javax.swing.JLabel();
jLabelData = new javax.swing.JLabel();
jLabelVazio = new javax.swing.JLabel();
jXImagePanel1 = new org.jdesktop.swingx.JXImagePanel();
jLabelLogo = new javax.swing.JLabel();
jButtonLoginSair = new javax.swing.JButton();
jButtonAgenda = new javax.swing.JButton();
jButtonCadMedico = new javax.swing.JButton();
jButtonCadPacientes = new javax.swing.JButton();
jLabeImglCabecalho = new javax.swing.JLabel();
jLabeImglCabecalho1 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenuCadastro = new javax.swing.JMenu();
jMenuItemCadMedico = new javax.swing.JMenuItem();
jMenuItemCadPaciente = new javax.swing.JMenuItem();
jMenuItemCadUsuario = new javax.swing.JMenuItem();
jMenuRelatórios = new javax.swing.JMenu();
jMenuItemUsuCad = new javax.swing.JMenuItem();
jMenuFerramentas = new javax.swing.JMenu();
jMenuSair = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItemSair = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SystemLife (Versão 1.0)");
setBackground(new java.awt.Color(255, 255, 255));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jLabelUsuario.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabelUsuario.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelUsuario.setText(" ");
jLabelUsuario.setAlignmentX(2.0F);
jLabelUsuario.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 153, 153)));
jLabelHora.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabelHora.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelHora.setAlignmentY(2.0F);
jLabelHora.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 153, 153)));
jLabelHora.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabelData.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabelData.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelData.setAlignmentY(2.0F);
jLabelData.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 153, 153)));
jLabelData.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabelData.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsListener() {
public void ancestorMoved(java.awt.event.HierarchyEvent evt) {
}
public void ancestorResized(java.awt.event.HierarchyEvent evt) {
jLabelDataAncestorResized(evt);
}
});
jLabelVazio.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelVazio.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 153, 153)));
jLabelVazio.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsListener() {
public void ancestorMoved(java.awt.event.HierarchyEvent evt) {
}
public void ancestorResized(java.awt.event.HierarchyEvent evt) {
jLabelVazioAncestorResized(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabelData, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabelHora, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelVazio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 794, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelHora, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabelUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
.addComponent(jLabelData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelVazio, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE))
);
jXImagePanel1.setBackground(new java.awt.Color(255, 255, 255));
jLabelLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Logo2.png"))); // NOI18N
jButtonLoginSair.setBackground(new java.awt.Color(255, 255, 255));
jButtonLoginSair.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButtonLoginSair.setText("SAIR");
jButtonLoginSair.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 3, true));
jButtonLoginSair.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButtonLoginSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonLoginSairActionPerformed(evt);
}
});
jButtonAgenda.setBackground(new java.awt.Color(255, 255, 255));
jButtonAgenda.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButtonAgenda.setText("AGENDAMENTO");
jButtonAgenda.setToolTipText("Agendamento");
jButtonAgenda.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 3, true));
jButtonAgenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButtonAgenda.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAgendaActionPerformed(evt);
}
});
jButtonCadMedico.setBackground(new java.awt.Color(255, 255, 255));
jButtonCadMedico.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButtonCadMedico.setText("MÉDICOS");
jButtonCadMedico.setToolTipText("Médicos");
jButtonCadMedico.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 3, true));
jButtonCadMedico.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButtonCadMedico.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCadMedicoActionPerformed(evt);
}
});
jButtonCadPacientes.setBackground(new java.awt.Color(255, 255, 255));
jButtonCadPacientes.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jButtonCadPacientes.setText("NOVO ATENDIMENTO");
jButtonCadPacientes.setToolTipText("Novo Atendimento");
jButtonCadPacientes.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 3, true));
jButtonCadPacientes.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButtonCadPacientes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCadPacientesActionPerformed(evt);
}
});
jLabeImglCabecalho.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cabecalho1.png"))); // NOI18N
jLabeImglCabecalho1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cabecalho2.png"))); // NOI18N
javax.swing.GroupLayout jXImagePanel1Layout = new javax.swing.GroupLayout(jXImagePanel1);
jXImagePanel1.setLayout(jXImagePanel1Layout);
jXImagePanel1Layout.setHorizontalGroup(
jXImagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabeImglCabecalho, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(jXImagePanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabelLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addComponent(jLabeImglCabecalho1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(jXImagePanel1Layout.createSequentialGroup()
.addGap(411, 411, 411)
.addGroup(jXImagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButtonLoginSair, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonCadPacientes, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonCadMedico, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(59, Short.MAX_VALUE))
);
jXImagePanel1Layout.setVerticalGroup(
jXImagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jXImagePanel1Layout.createSequentialGroup()
.addComponent(jLabeImglCabecalho, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabelLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(47, 47, 47)
.addComponent(jButtonCadPacientes, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonCadMedico, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonLoginSair, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
.addComponent(jLabeImglCabecalho1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jMenuBar1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jMenuCadastro.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jMenuCadastro.setText("Cadastro");
jMenuItemCadMedico.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
jMenuItemCadMedico.setText("Médicos");
jMenuItemCadMedico.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemCadMedicoActionPerformed(evt);
}
});
jMenuCadastro.add(jMenuItemCadMedico);
jMenuItemCadPaciente.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
jMenuItemCadPaciente.setText("Pacientes");
jMenuCadastro.add(jMenuItemCadPaciente);
jMenuItemCadUsuario.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
jMenuItemCadUsuario.setText("Usuários");
jMenuItemCadUsuario.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemCadUsuarioActionPerformed(evt);
}
});
jMenuCadastro.add(jMenuItemCadUsuario);
jMenuBar1.add(jMenuCadastro);
jMenuRelatórios.setText("Relatórios");
jMenuItemUsuCad.setText("Usuários cadastrados");
jMenuItemUsuCad.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemUsuCadActionPerformed(evt);
}
});
jMenuRelatórios.add(jMenuItemUsuCad);
jMenuBar1.add(jMenuRelatórios);
jMenuFerramentas.setText("Ferramentas");
jMenuBar1.add(jMenuFerramentas);
jMenuSair.setText("Sair");
jMenuSair.setToolTipText("Sair");
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Button-Log-Off-icon.png"))); // NOI18N
jMenuItem1.setText("Logout");
jMenuItem1.setToolTipText("Logout");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenuSair.add(jMenuItem1);
jMenuItemSair.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
jMenuItemSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/exit2.png"))); // NOI18N
jMenuItemSair.setText("Sair");
jMenuItemSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItemSairActionPerformed(evt);
}
});
jMenuSair.add(jMenuItemSair);
jMenuBar1.add(jMenuSair);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jXImagePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jXImagePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
setSize(new java.awt.Dimension(746, 705));
setLocationRelativeTo(null);
}// </editor-fold>
private void jMenuItemCadMedicoActionPerformed(java.awt.event.ActionEvent evt) {
try {
conecta.executaSql("select * from usuarios where usu_usu ='"+jLabelUsuario.getText()+"'");
conecta.rs.first();
if(conecta.rs.getString("usu_tipo").equals("Administrador")){
if(tela==null){
tela = new FormMedico();
tela.setVisible(true);
tela.setResizable(false);
}else{
tela.setVisible(true);
tela.setResizable(false);
}
//FormMedico tela = new FormMedico();
//tela.setVisible(true);
}else{
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\n Contacte o administrador do sistema!");
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\nContacte o administrador do sistema!");
}
}
private void jMenuItemCadUsuarioActionPerformed(java.awt.event.ActionEvent evt) {
try {
conecta.executaSql("select * from usuarios where usu_usu ='"+jLabelUsuario.getText()+"'");
conecta.rs.first();
if(conecta.rs.getString("usu_tipo").equals("Administrador")){
if(telaUsu==null){
telaUsu = new FormUsuario();
telaUsu.setVisible(true);
telaUsu.setResizable(false);
}else{
telaUsu.setVisible(true);
telaUsu.setResizable(false);
}
//FormUsuario tela = new FormUsuario();
//tela.setVisible(true);
}else{
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\n Contacte o administrador do sistema!");
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\nContacte o administrador do sistema!");
}
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
Date dataSistema = new Date();
SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
jLabelData.setText(formato.format(dataSistema));
Timer timer = new Timer(1000, new hora());
timer.start();
}
private Connection ConexaoBD() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
class hora implements ActionListener{
@Override
public void actionPerformed(ActionEvent e){
Calendar now = Calendar.getInstance();
jLabelHora.setText((String.format("%1$tH:%1$tM:%1$tS", now)));
}
}
private void jMenuItemSairActionPerformed(java.awt.event.ActionEvent evt) {
int i = JOptionPane.showConfirmDialog(null ,"Tem certeza que deseja sair?", "Confirmação de sair...",JOptionPane.YES_NO_OPTION);
System.out.println("I" + i);
if (i == JOptionPane.YES_OPTION ) {
System.exit(0);
} else {
System.out.println("NAO FECHA JANELA");
repaint();
}
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
String usuario = null;
TelaPrincipal tela = new TelaPrincipal(usuario);
tela.setVisible(false);
dispose();
new TelaLogin().setVisible(true);
}
private void jLabelDataAncestorResized(java.awt.event.HierarchyEvent evt) {
// TODO add your handling code here:
}
private void jLabelVazioAncestorResized(java.awt.event.HierarchyEvent evt) {
// TODO add your handling code here:
}
private void jButtonCadPacientesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtonCadMedicoActionPerformed(java.awt.event.ActionEvent evt) {
try {
conecta.executaSql("select * from usuarios where usu_usu ='"+jLabelUsuario.getText()+"'");
conecta.rs.first();
if(conecta.rs.getString("usu_tipo").equals("Administrador")){
if(tela==null){
tela = new FormMedico();
tela.setVisible(true);
tela.setResizable(false);
}else{
tela.setVisible(true);
tela.setResizable(false);
}
//FormMedico tela = new FormMedico();
//tela.setVisible(true);
}else{
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\n Contacte o administrador do sistema!");
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(rootPane, "Você não tem permissão para essa função!\nContacte o administrador do sistema!");
}
}
private void jButtonAgendaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtonLoginSairActionPerformed(java.awt.event.ActionEvent evt) {
int i = JOptionPane.showConfirmDialog(null ,"Tem certeza que deseja sair?", "Confirmação de sair...",JOptionPane.YES_NO_OPTION);
System.out.println("I" + i);
if (i == JOptionPane.YES_OPTION ) {
System.exit(0);
} else {
System.out.println("NAO FECHA JANELA");
repaint();
}
}
private void jMenuItemUsuCadActionPerformed(java.awt.event.ActionEvent evt) {
int confirma = JOptionPane.showConfirmDialog(null, "Confirma a impressão desse relatório?","Atenção", JOptionPane.YES_NO_OPTION);
if (confirma == JOptionPane.YES_OPTION){
try {
JasperPrint print = JasperFillManager.fillReport("C:/Relatorios_ireport/Relatorio_usu.jasper",null,conexao);
JasperViewer.viewReport(print,false);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String usuario = null;
new TelaPrincipal(usuario).setVisible(true);
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TelaPrincipal(usuario).setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButtonAgenda;
private javax.swing.JButton jButtonCadMedico;
private javax.swing.JButton jButtonCadPacientes;
private javax.swing.JButton jButtonLoginSair;
private javax.swing.JLabel jLabeImglCabecalho;
private javax.swing.JLabel jLabeImglCabecalho1;
private javax.swing.JLabel jLabelData;
private javax.swing.JLabel jLabelHora;
private javax.swing.JLabel jLabelLogo;
private javax.swing.JLabel jLabelUsuario;
private javax.swing.JLabel jLabelVazio;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenu jMenuCadastro;
private javax.swing.JMenu jMenuFerramentas;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItemCadMedico;
private javax.swing.JMenuItem jMenuItemCadPaciente;
private javax.swing.JMenuItem jMenuItemCadUsuario;
private javax.swing.JMenuItem jMenuItemSair;
private javax.swing.JMenuItem jMenuItemUsuCad;
private javax.swing.JMenu jMenuRelatórios;
private javax.swing.JMenu jMenuSair;
private javax.swing.JPanel jPanel1;
private org.jdesktop.swingx.JXImagePanel jXImagePanel1;
// End of variables declaration
}
Sendo que o erro está nessa linha abaixo.
private void jMenuItemUsuCadActionPerformed(java.awt.event.ActionEvent evt) {
int confirma = JOptionPane.showConfirmDialog(null, "Confirma a impressão desse relatório?","Atenção", JOptionPane.YES_NO_OPTION);
if (confirma == JOptionPane.YES_OPTION){
try {
JasperPrint print = JasperFillManager.fillReport("C:/Relatorios_ireport/Relatorio_usu.jasper",null,conexao);
JasperViewer.viewReport(print,false);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}