我有两个类。
- GUI(包含主方法)
- Parser(读取文件(csv),使用它们,然后写入新文件)
我的GUI中有一个TextArea,它应该是日志窗口。
在这个窗口中,我想要来自解析器类的信息,因此我创建了以下部分:
//object that should be accessible from the GUI class
private String logText;
// in this part of the parser class i go through each line of the file
// i want the first line in my log (next)
while (sc.hasNextLine()) {
prev = curr;
curr = next;
next = sc.nextLine();
if(onlyonce=true){
logText=x;
onlyonce=false;
}
这段代码使我能够获得第一行代码,并将其放入类的私有属性中。
如何将这些信息输入到gui类中?
任何建议。
关于
Class MyBean{
String str;
int curr,next,prev;
}
parser
类中的设置值
MyBean objBean = new Bean();
objBeam.curr=YourValue;...
然后在GUI
类和getvalue
中创建Object作为设置值。您也可以使用getter
setter
方法!