显示GUI中包含的表 [英] display a table contained in a GUI

查看:46
本文介绍了显示GUI中包含的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



在我的代码中,当我点击显示结果按钮时,它显示结果是除了主要的另一个界面中的表接口,untel现在一切都很好但是当我改变方法时:我只想在主界面中显示这个表,我创建了一个新的面板,所有,问题是在这个面板中显示这个表的问题所以这里:代码

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

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);

面板:



这里是显示结果按钮代码:



panel:

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

推荐答案

5.actionPerformed(GUI2.java: 363
at javax .swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton
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 (未知来源)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component .processMouseEvent(未知来源)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent (未知来源)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown)来源)
at java.awt.LightweightDispatcher.retargetMouseEve nt(未知来源)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(未知来源)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) )java.awt.EventQueue.access上的
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(未知来源)
at java.awt.EventQueue
200(Unknown Source) at java.awt.EventQueue


这篇关于显示GUI中包含的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆