有一个小问题,不确定如何调用特定函数来打印其详细信息。我创建了一个单选按钮,用于检查 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......