Hi everyone!
In my code when I click on the "Show Results" button it shows me the result is a table in another interface other than the main interface, untel now everything is fine but when I changed the method : I just want to show this table in the main interface, I created a new panel and all, the problem is a problem of showing this table in this panel so here: the code of the panel:
JPanel panel_4 = new JPanel();
panel_4.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel_4.setBounds(115, 510, 450, 130);
getContentPane().add(panel_4);
panel_4.setLayout(null);
JLabel lblNewLabel = new JLabel("Resource Aware Planning Results" );
lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 14));
lblNewLabel.setBounds(125, 11, 236, 14);
panel_4.add(lblNewLabel);
JScrollPane scrollPane1 = new JScrollPane();
scrollPane1.setBounds(66, 55, 312, 49);
panel_4.add(scrollPane1);
table = new JTable();
scrollPane1.setViewportView(table);
DefaultTableModel modelres = new DefaultTableModel();
modelres.setRowCount(1);
DefaultTableModel modelres1 = new DefaultTableModel();
modelres1.setRowCount(1);
and here is the Show Results button code:
if ( radio3.isSelected())
{
for(int i=0; i<n;i++)
{
//int k=i+1;
String object = "T"+i;
modelres.addColumn(object);// modelres est globale ainsi que modelres1
int index=plan.NodeIndex(i, res, m);
object="N"+index;
modelres.setValueAt(object, 0, i);
}
table.setModel(modelres);
//resultsFrame.setVisible(true);
}
else if ( radio4.isSelected())
{
for(int i=0; i<n;i++)
{
//int k=i+1;
String object = "T"+i;
modelres1.addColumn(object);
int index=plan.NodeIndex(i, res, m);
object="N"+index;
modelres1.setValueAt(object, 0, i);
}
table.setModel(modelres1);
//resultsFrame.setVisible(true);
}
and it shows me this error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at projetPFE.GUI2.btnShowResults(GUI2.java:978)
at projetPFE.GUI2$5.actionPerformed(GUI2.java:363)
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.plaf.basic.BasicButtonListener.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$200(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$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.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$1.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)
I honestly do not know how to fix this error
I'll be very grateful if you can help me
Thank you in advance