boa noite amigos (as)
estou tendo um erro estranho que nçao esotu entendendo o programa que estou tentando fazer tem uma frame com jdektop para achamar varias internalframes so que estava abrindo normal agora ele da erro nao abrer mais as janelas estou sendo entender o erro que esta dando é este :
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at Tela_incial.Principal$2.actionPerformed(Principal.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
aqui esta o codigos do programas que estou tentando fazer :
tela principal:
package Tela_incial;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import Alertas.Qual_Filial;
import Compras.Mercadorias;
import Compras.Produtos_Internos;
import Compras.Veiculos;
import Contatos.Clientes;
import Contatos.Filiais;
import Contatos.Fornecedores;
import Contatos.Funcionarios;
import Financeiro.Contas_a_Apagar;
import Financeiro.Contas_a_Receber;
import Financeiro.Contratos;
import lib.AtualizadorHorario;
public class Principal extends JFrame {
/**
*
*/
private static final long serialVersionUID = -6583549646774796091L;
public JDesktopPane desktop;
private JPanel contentPane;
private JLabel relogio;
private Contratos FinanContr;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Principal frame = new Principal();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void mostrarHora() {
AtualizadorHorario ah = new AtualizadorHorario(relogio);
ah.mostrarData(true);
Thread thHora = ah;
thHora.start();
}
/**
* Create the frame.
*/
public Principal() {
setTitle("estudo de java comercial:");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 967, 442);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));
this.setExtendedState(MAXIMIZED_BOTH);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date hora = Calendar.getInstance().getTime(); // Ou qualquer outra forma que tem
String dataFormatada = sdf.format(hora);
JMenuBar menu = new JMenuBar();
contentPane.add(menu, BorderLayout.NORTH);
menu.setFont(new Font("Arial Black", Font.BOLD, 15));
menu.setVisible(true);
JMenu mnContatos = new JMenu("Contatos");
menu.add(mnContatos);
JMenuItem tpmconFuncionarios = new JMenuItem("Funcionarios");
tpmconFuncionarios.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Funcionarios contFunci = new Funcionarios();
desktop.add(contFunci, MAXIMIZED_BOTH);
contFunci.setVisible(true);
}
}
);
mnContatos.add(tpmconFuncionarios);
JMenuItem tpmconClientes = new JMenuItem("Clientes");
tpmconClientes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Clientes Contclie = new Clientes();
desktop.add(Contclie);
Contclie.setVisible(true);
try {
Contclie.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnContatos.add(tpmconClientes);
JMenuItem tpmconconFornecedores = new JMenuItem("Fornecedores");
tpmconconFornecedores.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Fornecedores Contfor = new Fornecedores();
desktop.add(Contfor);
Contfor.setVisible(true);
try {
Contfor.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnContatos.add(tpmconconFornecedores);
JMenuItem tpmconFiliais = new JMenuItem("Filiais");
tpmconFiliais.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Filiais Contfili = new Filiais();
desktop.add(Contfili);
Contfili.setVisible(true);
try {
Contfili.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnContatos.add(tpmconFiliais);
JMenu mnCompras = new JMenu("Compras");
menu.add(mnCompras);
JMenuItem mntmProdutos = new JMenuItem("Produtos Internos");
mntmProdutos.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Produtos_Internos CompProdu = new Produtos_Internos();
desktop.add(CompProdu);
CompProdu.setVisible(true);
try {
CompProdu.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnCompras.add(mntmProdutos);
JMenuItem mntmMercadorias = new JMenuItem("Mercadorias");
mntmMercadorias.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Mercadorias CompMerc = new Mercadorias();
desktop.add(CompMerc);
CompMerc.setVisible(true);
try {
CompMerc.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnCompras.add(mntmMercadorias);
JMenuItem mntmVeiculos = new JMenuItem("Veiculos");
mntmVeiculos.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Veiculos CompVeicu = new Veiculos();
desktop.add(CompVeicu);
CompVeicu.setVisible(true);
try {
CompVeicu.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnCompras.add(mntmVeiculos);
JMenu mnFinaceiro = new JMenu("Financeiro");
menu.add(mnFinaceiro);
JMenuItem mntmContasAReceber = new JMenuItem("Contas a receber");
mntmContasAReceber.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Contas_a_Receber FinanRecer = new Contas_a_Receber();
desktop.add(FinanRecer);
FinanRecer.setVisible(true);
try {
FinanRecer.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnFinaceiro.add(mntmContasAReceber);
JMenuItem mntmContasAApagar = new JMenuItem("Contas a Apagar");
mntmContasAApagar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Contas_a_Apagar FinanApa = new Contas_a_Apagar();
desktop.add(FinanApa);
FinanApa.setVisible(true);
try {
FinanApa.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
mnFinaceiro.add(mntmContasAApagar);
JMenuItem mntmContratos = new JMenuItem("Contratos");
mnFinaceiro.add(mntmContratos);
JMenu mnRelatorios = new JMenu("Relatorios");
menu.add(mnRelatorios);
JMenuItem mntmFuncionario = new JMenuItem("Contatos");
mntmFuncionario.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Qual_Filial AlerQual = new Qual_Filial();
AlerQual.setVisible(true);
}
});
mnRelatorios.add(mntmFuncionario);
JMenuItem mntmFornecedor = new JMenuItem("Compras");
mntmFornecedor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Qual_Filial AlerQual = new Qual_Filial();
AlerQual.setVisible(true);
}
});
mnRelatorios.add(mntmFornecedor);
JMenuItem mntmFial = new JMenuItem("Financeiro");
mntmFial.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Qual_Filial AlerQual = new Qual_Filial();
AlerQual.setVisible(true);
}
});
mnRelatorios.add(mntmFial);
JDesktopPane desktop = new JDesktopPane();
contentPane.add(desktop, BorderLayout.CENTER);
desktop.setBackground(Color.WHITE);
JPanel panel = new JPanel();
contentPane.add(panel, BorderLayout.SOUTH);
relogio = new JLabel(dataFormatada);
panel.add(relogio);
relogio.setBackground(UIManager.getColor("Button.darkShadow"));
relogio.setFont(new Font("Tahoma", Font.BOLD, 26));
mostrarHora();
mntmContratos.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
FinanContr = new Contratos();
desktop.add(FinanContr);
FinanContr.setVisible(true);
FinanContr.setMaximum(true);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
);
}
}
telas segundarias:
package Contatos;
import java.awt.EventQueue;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Funcionarios extends JInternalFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Funcionarios frame = new Funcionarios();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Funcionarios() {
setTitle("Cadastro de Funcionarios");
setClosable(true);
setBounds(100, 100, 450, 300);
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.SOUTH);
JButton btnSair = new JButton("Sair");
btnSair.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object[] options = {"Sim", "Não"};
int i = JOptionPane.showOptionDialog(null,
"Tem certeza que deseja sair dos cadastro de Funcionarios?", "ATENÇÃO",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
options, options[0]);
if (i == JOptionPane.YES_OPTION) {
Funcionarios.this.dispose();
}} });
panel.add(btnSair);
}
}
outra tela
package Contatos;
import java.awt.EventQueue;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JLabel;
import java.awt.Insets;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
public class Fornecedores extends JInternalFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField tfcoddofornecedor;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Fornecedores frame = new Fornecedores();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Fornecedores() {
setTitle("Cadastro de Fornecedores");
setClosable(true);
setBounds(100, 100, 820, 525);
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{804, 0};
gridBagLayout.rowHeights = new int[]{462, 33, 0};
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
getContentPane().setLayout(gridBagLayout);
JPanel panel_1 = new JPanel();
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
gbc_panel_1.insets = new Insets(0, 0, 5, 0);
gbc_panel_1.fill = GridBagConstraints.BOTH;
gbc_panel_1.gridx = 0;
gbc_panel_1.gridy = 0;
getContentPane().add(panel_1, gbc_panel_1);
GridBagLayout gbl_panel_1 = new GridBagLayout();
gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0};
gbl_panel_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_panel_1.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
panel_1.setLayout(gbl_panel_1);
JLabel lblCodDoFornecerdor = new JLabel("FORNECEDOR:");
lblCodDoFornecerdor.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_lblCodDoFornecerdor = new GridBagConstraints();
gbc_lblCodDoFornecerdor.insets = new Insets(0, 0, 5, 5);
gbc_lblCodDoFornecerdor.anchor = GridBagConstraints.EAST;
gbc_lblCodDoFornecerdor.gridx = 0;
gbc_lblCodDoFornecerdor.gridy = 0;
panel_1.add(lblCodDoFornecerdor, gbc_lblCodDoFornecerdor);
//deixa para ser digitado pelo usuario:
tfcoddofornecedor = new JTextField();
tfcoddofornecedor.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_tfcoddofornecedor = new GridBagConstraints();
gbc_tfcoddofornecedor.insets = new Insets(0, 0, 5, 5);
gbc_tfcoddofornecedor.fill = GridBagConstraints.HORIZONTAL;
gbc_tfcoddofornecedor.gridx = 1;
gbc_tfcoddofornecedor.gridy = 0;
panel_1.add(tfcoddofornecedor, gbc_tfcoddofornecedor);
tfcoddofornecedor.setColumns(10);
JLabel lblNomeDoFornecedor = new JLabel("CNPJ");
lblNomeDoFornecedor.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_lblNomeDoFornecedor = new GridBagConstraints();
gbc_lblNomeDoFornecedor.insets = new Insets(0, 0, 5, 5);
gbc_lblNomeDoFornecedor.anchor = GridBagConstraints.EAST;
gbc_lblNomeDoFornecedor.gridx = 2;
gbc_lblNomeDoFornecedor.gridy = 0;
panel_1.add(lblNomeDoFornecedor, gbc_lblNomeDoFornecedor);
// QUANDO BOTAO RADIO FOR CLICADO ANULAR ESTA FUNÇAO
textField = new JTextField();
textField.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_textField = new GridBagConstraints();
gbc_textField.gridwidth = 6;
gbc_textField.insets = new Insets(0, 0, 5, 5);
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
gbc_textField.gridx = 3;
gbc_textField.gridy = 0;
panel_1.add(textField, gbc_textField);
textField.setColumns(10);
//QUANDO ATIVO ANULA FUNÇÃO ACIMA
JRadioButton rdbtnSemCnpj = new JRadioButton("SEM CNPJ");
rdbtnSemCnpj.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_rdbtnSemCnpj = new GridBagConstraints();
gbc_rdbtnSemCnpj.insets = new Insets(0, 0, 5, 0);
gbc_rdbtnSemCnpj.gridx = 9;
gbc_rdbtnSemCnpj.gridy = 0;
panel_1.add(rdbtnSemCnpj, gbc_rdbtnSemCnpj);
JLabel lblTelefone = new JLabel("TELEFONE:");
lblTelefone.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_lblTelefone = new GridBagConstraints();
gbc_lblTelefone.anchor = GridBagConstraints.EAST;
gbc_lblTelefone.insets = new Insets(0, 0, 5, 5);
gbc_lblTelefone.gridx = 0;
gbc_lblTelefone.gridy = 1;
panel_1.add(lblTelefone, gbc_lblTelefone);
textField_1 = new JTextField();
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
gbc_textField_1.insets = new Insets(0, 0, 5, 5);
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
gbc_textField_1.gridx = 1;
gbc_textField_1.gridy = 1;
panel_1.add(textField_1, gbc_textField_1);
textField_1.setColumns(10);
JLabel lblMaterial = new JLabel("MATERIAL:");
lblMaterial.setFont(new Font("Tahoma", Font.BOLD, 15));
GridBagConstraints gbc_lblMaterial = new GridBagConstraints();
gbc_lblMaterial.anchor = GridBagConstraints.EAST;
gbc_lblMaterial.insets = new Insets(0, 0, 0, 5);
gbc_lblMaterial.gridx = 0;
gbc_lblMaterial.gridy = 2;
panel_1.add(lblMaterial, gbc_lblMaterial);
textField_2 = new JTextField();
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
gbc_textField_2.gridwidth = 9;
gbc_textField_2.insets = new Insets(0, 0, 0, 5);
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
gbc_textField_2.gridx = 1;
gbc_textField_2.gridy = 2;
panel_1.add(textField_2, gbc_textField_2);
textField_2.setColumns(10);
JPanel panel = new JPanel();
GridBagConstraints gbc_panel = new GridBagConstraints();
gbc_panel.anchor = GridBagConstraints.NORTH;
gbc_panel.fill = GridBagConstraints.HORIZONTAL;
gbc_panel.gridx = 0;
gbc_panel.gridy = 1;
getContentPane().add(panel, gbc_panel);
JButton btnSair = new JButton("Sair");
btnSair.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object[] options = {"Sim", "Não"};
int i = JOptionPane.showOptionDialog(null,
"Tem certeza que deseja sair dos cadastro de Fornecedores ?", "ATENÇÃO",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
options, options[0]);
if (i == JOptionPane.YES_OPTION) {
Fornecedores.this.dispose();
}} });
panel.add(btnSair);
}
}
nao vou posta todas senao vai fica muit extenso
obrigado pela ajuda desde ja
