简体   繁体   English

jtable(添加新行)

[英]jtable ( adding new row)

I am trying to implement a GUI for my tool by using Swing plugin. 我正在尝试通过使用Swing插件为我的工具实现GUI。

I have a jtable for every job and all the properties of the jobs are read by a csv file. 我为每个作业都有一个jtable,并且该作业的所有属性都由一个csv文件读取。 However if I want to create my special job ( in order to do it, I created another jframe which includes the properties of job like speed,property.. 但是,如果我想创建自己的特殊作业(为此,我创建了另一个jframe,其中包含作业的属性,例如速度,属性。

User can use either the default jobs or if he wants to add special his job, he clicks NewJob button and new frame will open and he chooses all properties of it. 用户可以使用默认作业,或者如果要添加特殊作业,请单击“新建作业”按钮,将打开新框架,并选择所有属性。 All of these I implemented. 所有这些我都实现了。

However, I want to add this new job in the table, below to the other default jobs and write all the properties of it in csv file. 但是,我想在下表中将此新作业添加到其他默认作业中,并将其所有属性写入csv文件。 How can I do this? 我怎样才能做到这一点? Advance thanks for all help. 预先感谢所有帮助。

Because of the confidentiality issues, I could not share my codes. 由于机密性问题,我无法共享我的代码。

I created another jframe... 我创建了另一个jframe ...

Don't use a JFrame. 不要使用JFrame。 Use a modal JDialog for child windows. 对子窗口使用模式JDialog。

I want to add this new job in the table 我想在表中添加这个新工作

Then you need to update the TableModel. 然后,您需要更新TableModel。

Use the addRow(...) method of the DefaultTableModel to dynamically add data to the TableModel. 使用DefaultTableModeladdRow(...)方法可将数据动态添加到TableModel。

and write all the properties of it in csv file. 并将其所有属性写入csv文件。

You create two loops, one for the rows and the other for the columns and your write out all the data in the TableMdoel to a file. 您创建两个循环,一个循环用于行,另一个循环用于列,然后将TableMdoel中的所有数据写出到文件中。

Since you won't share your code we can't give you a specific solution, only general advice. 由于您不会共享代码,因此我们无法为您提供特定的解决方案,只能提供一般建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM