我使用 Swing 创建了一个桌面应用程序。我需要收集应用程序中输入的信息,并在单击创建文件按钮时将该信息写入文件。我对此很陌生,请帮助我。下面的代码片段将信息打印到控制台,但如何将其写入文件
public void actionPerformed(ActionEvent e) {
String str = (String)comboBox1.getSelectedItem();
System.out.println("# Strategy: SAr, SPSL, PRISM, GANN, RRR \nstrategy="+str);
String str1 = (String)comboBox2.getSelectedItem();
System.out.println("\n# ss1 \nsupport-strategy="+str1);
String str2 = (String)comboBox3.getSelectedItem();
System.out.println("\n# silverm_i,silver_i,leadmini_i,lead_i,alumini_i,naturalgas_i,copperm_i,crudeoil_i,gold_i\ndata-source="+str2);
String str3 = (String)comboBox6.getSelectedItem();
System.out.println("\n# YES or NO\npositional-trading="+str3);
String str4 = (String)comboBox4.getSelectedItem();
System.out.println("\n# Data source options - DATABASE or CSV \ndata-from="+str4);
String str5 = (String)comboBox5.getSelectedItem();
System.out.println("\n# DEV or DEV \nenvironment="+str5);
String str6 = (String)comboBox7.getSelectedItem();
System.out.println("\n# Strategy: WAGHA_BORDER or REGULAR_TOP_BOTTOM_MOVEMENT_BASED_TREND (i.e. RBI) or REGULAR_TOP_BOTTOM_WITH_NO_TRADE_ZONE \ngann-strategy="+str6);
}
我有几个日期微调器对象,复选框也是如此。如何从这些组件中收集信息。