ola,
pessoal eu ja naum sei mais o que fazer, montei um projeto no netbeans, qdo executo pelo netbeans ele roda legal porém qdo vou executar o jar do proprío netbeans as minhas jDialog não abre, estou disponibilizando o código para uma analise, se algum puder ajudar serei totalmente grato, detalhe: gerei o jar externamente, fora do netbeans e acontece a mesma coisa.
:?
/*
* MenuPrincipal.java
*
* Created on 28 de Março de 2005, 09:01
*/
package transportes;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import javax.swing.UIManager;
import java.sql.*;
/**
*
* @author Administrator
*/
public class MenuPrincipal extends javax.swing.JFrame {
/** Creates new form MenuPrincipal */
public MenuPrincipal() {
h = dim.height;
w = dim.width;
initComponents();
setSize(w, h);
pFundo = new JPanel();
getContentPane().add(pFundo);
pFundo.setBounds(0,0, w,h);
pFundo.setBackground(new Color(153,153,153));
pFundo.setBorder(new javax.swing.border.EtchedBorder());
pFundo.setComponentPopupMenu(mpPrincipal);
selectLAF();
}
public void AlteraValorLAF(int cod)
{
conecta();
try
{
query = "update tab_confLAF set cod_confLAF = \"" + cod + "\"";
stm = con.prepareStatement(query);
stm.execute();
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null,ex,"Erro",JOptionPane.ERROR_MESSAGE);
}
selectLAF();
}
public void conecta()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://192.168.4.3:3306/dbtransp",user, passwd);
}
catch (ClassNotFoundException ex)
{
JOptionPane.showMessageDialog(null,ex,"Erro",JOptionPane.ERROR_MESSAGE);
}
catch (SQLException ex)
{
JOptionPane.showMessageDialog(null,ex,"Erro",JOptionPane.ERROR_MESSAGE);
}
}
public void selectLAF()
{
conecta();
try
{
query = "select * from tab_confLAF";
stm = con.prepareStatement(query);
rs = stm.executeQuery();
if(rs.next())
{
mudaLAF(rs.getInt("cod_confLAF"));
}
}
catch (SQLException ex)
{
JOptionPane.showMessageDialog(null,ex,"Erro",JOptionPane.ERROR_MESSAGE);
}
}
public void mudaLAF(int index)
{
looks = UIManager.getInstalledLookAndFeels();
try
{
UIManager.setLookAndFeel(looks[index].getClassName());
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e,"Erro",JOptionPane.ERROR_MESSAGE);
}
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
mpPrincipal = new javax.swing.JPopupMenu();
mpitemSair = new javax.swing.JMenuItem();
jMenuBar1 = new javax.swing.JMenuBar();
mCadastro = new javax.swing.JMenu();
itmLomb = new javax.swing.JMenuItem();
itmRota = new javax.swing.JMenuItem();
itmTipoVeic = new javax.swing.JMenuItem();
imtTransp = new javax.swing.JMenuItem();
itmVeic = new javax.swing.JMenuItem();
itmVend = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JSeparator();
itmFechar = new javax.swing.JMenuItem();
mMovto = new javax.swing.JMenu();
itmCarga = new javax.swing.JMenuItem();
mWindow = new javax.swing.JMenu();
itmLAF = new javax.swing.JMenu();
itmMotif = new javax.swing.JMenuItem();
itmWindow = new javax.swing.JMenuItem();
itmMetal = new javax.swing.JMenuItem();
itmLiquid = new javax.swing.JMenuItem();
mRelatorio = new javax.swing.JMenu();
rMovEmb = new javax.swing.JMenuItem();
mpPrincipal.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
mpitemSair.setFont(new java.awt.Font("Arial", 0, 11));
mpitemSair.setMnemonic('S');
mpitemSair.setText("Sair do Programa");
mpitemSair.setOpaque(false);
mpitemSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mpitemSairActionPerformed(evt);
}
});
mpPrincipal.add(mpitemSair);
getContentPane().setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Transportes - Menu Principal");
mCadastro.setMnemonic('C');
mCadastro.setFont(new java.awt.Font("Arial", 0, 11));
mCadastro.setLabel("Cadastros");
itmLomb.setFont(new java.awt.Font("Arial", 0, 11));
itmLomb.setText("Lombador");
itmLomb.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmLombActionPerformed(evt);
}
});
mCadastro.add(itmLomb);
itmRota.setFont(new java.awt.Font("Arial", 0, 11));
itmRota.setText("Rota");
itmRota.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmRotaActionPerformed(evt);
}
});
mCadastro.add(itmRota);
itmTipoVeic.setFont(new java.awt.Font("Arial", 0, 11));
itmTipoVeic.setText("Tipo de Ve\u00edculo");
itmTipoVeic.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmTipoVeicActionPerformed(evt);
}
});
mCadastro.add(itmTipoVeic);
imtTransp.setFont(new java.awt.Font("Arial", 0, 11));
imtTransp.setText("Transportadora");
imtTransp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
imtTranspActionPerformed(evt);
}
});
mCadastro.add(imtTransp);
itmVeic.setFont(new java.awt.Font("Arial", 0, 11));
itmVeic.setText("Ve\u00edculo");
itmVeic.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmVeicActionPerformed(evt);
}
});
mCadastro.add(itmVeic);
itmVend.setFont(new java.awt.Font("Arial", 0, 11));
itmVend.setText("Vendedor");
itmVend.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmVendActionPerformed(evt);
}
});
mCadastro.add(itmVend);
mCadastro.add(jSeparator1);
itmFechar.setFont(new java.awt.Font("Arial", 0, 11));
itmFechar.setMnemonic('S');
itmFechar.setText("Sair");
itmFechar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmFecharActionPerformed(evt);
}
});
mCadastro.add(itmFechar);
jMenuBar1.add(mCadastro);
mMovto.setMnemonic('M');
mMovto.setText("Movimenta\u00e7\u00e3o");
mMovto.setFont(new java.awt.Font("Arial", 0, 11));
itmCarga.setFont(new java.awt.Font("Arial", 0, 11));
itmCarga.setText(" Cargas Di\u00e1rias");
itmCarga.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmCargaActionPerformed(evt);
}
});
mMovto.add(itmCarga);
jMenuBar1.add(mMovto);
mWindow.setMnemonic('W');
mWindow.setText("Window");
mWindow.setFont(new java.awt.Font("Arial", 0, 11));
itmLAF.setText("Look And Feel");
itmLAF.setFont(new java.awt.Font("Arial", 0, 11));
itmMotif.setFont(new java.awt.Font("Arial", 0, 11));
itmMotif.setText("Motif");
itmMotif.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmMotifActionPerformed(evt);
}
});
itmLAF.add(itmMotif);
itmWindow.setFont(new java.awt.Font("Arial", 0, 11));
itmWindow.setText("Windows");
itmWindow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmWindowActionPerformed(evt);
}
});
itmLAF.add(itmWindow);
itmMetal.setFont(new java.awt.Font("Arial", 0, 11));
itmMetal.setText("Metal");
itmMetal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmMetalActionPerformed(evt);
}
});
itmLAF.add(itmMetal);
itmLiquid.setFont(new java.awt.Font("Arial", 0, 11));
itmLiquid.setText("Liquid");
itmLiquid.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itmLiquidActionPerformed(evt);
}
});
itmLAF.add(itmLiquid);
mWindow.add(itmLAF);
jMenuBar1.add(mWindow);
mRelatorio.setFont(new java.awt.Font("Arial", 0, 11));
mRelatorio.setLabel("Relat\u00f3rios");
rMovEmb.setText("Item");
rMovEmb.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rMovEmbActionPerformed(evt);
}
});
mRelatorio.add(rMovEmb);
jMenuBar1.add(mRelatorio);
setJMenuBar(jMenuBar1);
pack();
}
// </editor-fold>
private void itmLiquidActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AlteraValorLAF(4);
}
private void itmMetalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AlteraValorLAF(2);
}
private void itmWindowActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AlteraValorLAF(1);
}
private void itmMotifActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AlteraValorLAF(0);
}
private void rMovEmbActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
RelMovEmbarque relMovEmb = new RelMovEmbarque(null, true);
relMovEmb.show();
}
private void itmCargaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new MovEmbarque(null,false).show();
}
private void mpitemSairActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void itmVeicActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadVeic().show();
}
private void itmTipoVeicActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadTipoVeic().show();
}
private void itmVendActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadVend().show();
}
private void itmRotaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadRota().show();
}
private void imtTranspActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadTransp().show();
}
private void itmLombActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CadLomb().show();
}
private void itmFecharActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MenuPrincipal().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem imtTransp;
private javax.swing.JMenuItem itmCarga;
private javax.swing.JMenuItem itmFechar;
private javax.swing.JMenu itmLAF;
private javax.swing.JMenuItem itmLiquid;
private javax.swing.JMenuItem itmLomb;
private javax.swing.JMenuItem itmMetal;
private javax.swing.JMenuItem itmMotif;
private javax.swing.JMenuItem itmRota;
private javax.swing.JMenuItem itmTipoVeic;
private javax.swing.JMenuItem itmVeic;
private javax.swing.JMenuItem itmVend;
private javax.swing.JMenuItem itmWindow;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JMenu mCadastro;
private javax.swing.JMenu mMovto;
private javax.swing.JMenu mRelatorio;
private javax.swing.JMenu mWindow;
private javax.swing.JPopupMenu mpPrincipal;
private javax.swing.JMenuItem mpitemSair;
private javax.swing.JMenuItem rMovEmb;
// End of variables declaration
public Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
public int h = dim.height;
public int w = dim.width;
public JPanel pFundo = null;
public UIManager.LookAndFeelInfo looks[];
public Connection con = null;
public String query = null;
public PreparedStatement stm = null;
public ResultSet rs = null;
public int codConsulta;
}