manel1989 | Salut tout le monde!
dans mon code il me lorsque je clique sur le bouton "Show Results" il m'affiche le résultat souhaité qui est un tableau dans une autre interface autre que l'interface principale , jusqu'au la tout est bien mais lorsque j'ai changé de méthode c'est à dire je veux juste afficher ce tableau dans l'interface principale , j'ai créé un nouveau panel et tout , le problème c'est un probèlem d'affichage de ce tableau dans ce panel donc voici : le code du panel:
Code :
- 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);
|
et voici le code du bouton Show Results:
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);
- }
|
et il m'affiche cette erreur :
Code :
- 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)
|
je sais pas honnetement comment fixer cette errur je serai très reconnaissonte si vous pouvez m'aider
Merci d'avance ---------------
when there is a will there is a way
|