【发布时间】:2012-12-05 17:02:42
【问题描述】:
有一个小问题,不确定如何调用特定函数来打印其详细信息。 我创建了一个单选按钮,用于检查 PC 上的总物理内存,还有一个用于 GPU,两者都可以正常工作。
现在我不知道如何调用相同的函数,以便在我对特定系统属性进行系统扫描时打印在更大的窗口中。
if (isWindows()) {
jTextArea1.setText(header + "User Name : " + name
+ "\nOperating System :" + jComboBox1.getSelectedItem()
+ "\nSelected Gamer Ability : " + this.jComboBox4.getSelectedItem()
+ "\nSelected Age Group :" + this.jComboBox5.getSelectedItem()
+ "\nSystem Version : " + System.getProperty("os.version")
+ "\nSystem Architecture : " + System.getProperty("os.arch")
PROBLEM PART + "\nSystem Total Ram : " + this.jRadioButton2......
+ "\nScan ID : " + n + "\n \n")
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String filepath = "..\\Checker\\src\\batchchecker\\memory.bat";
try
{
Process p = Runtime.getRuntime().exec(filepath); // filepath
p.waitFor();
InputStream in = p.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int c = -1;
while ((c = in.read()) != -1)
{
baos.write(c);
}
String response = new String(baos.toByteArray());
jRadioButton2.setText(evt.getActionCommand());
JOptionPane.showMessageDialog(null, "" + evt.getActionCommand()
+ response);
}
catch (Exception e)
{
e.printStackTrace(System.err);
}
}
}
正如您从上面的代码中看到的那样,我的收音机做了它需要做的事情并经过了测试。我只是不确定如何将相同的结果调用到更大的图景中,它实际打印所有细节以及其余部分。代码行是+ "\nSystem Total Ram : " + this.jRadioButton2......
【问题讨论】:
-
您希望
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)再次运行吗?我觉得我没看清楚……
标签: java swing processbuilder