Quando tento capturar o conteudo da JCombobox acontece o erro
onde estou errando?
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
public class Imprimir {
private String sPorta;
public void imprimir_cheque() throws InterruptedException
{
SerialPort serialPort;
Form1 form1;
JOptionPane.showMessageDialog(null, " entrou imprimir cheque" );
try
{
form1=new Form1();
**JComboBox combo=form1.getJComboPorta();
sPorta=(String) combo.getSelectedItem();**
JOptionPane.showMessageDialog(null, "Porta Imprimir " + sPorta);
serialPort = new SerialPort (sPorta);
Form1
public class Form1 extends javax.swing.JFrame {
Imprimir imprimir;
JComboBox JComboPorta;
/**
* Creates new form Form1
*/
public Form1() {
initComponents();
DefaultComboBoxModel(SerialPortList.getPortNames()));
}
public JComboBox getJComboPorta() {
return JComboPorta;
}