我只是想知道如何将NsLookupGUI程序中单独的NsLookup程序的输出获取到TextArea中?
我有一个ActionListener;
private class buttonPressed implements ActionListener {
public void actionPerformed(ActionEvent a) {
getText = userInputBox.getText();
lookup.resolve(getText);
results.append(getText + "\n");
}
调用Nslookup类。但是,输出显示在终端中,而不是TextArea。
下面的代码是我的NsLookup程序;
public class NsLookup {
private InetAddress iNet = null;
public void resolve(String hostName) {
try {
iNet = InetAddress.getByName(hostName);
System.out.println("Host Name: " + iNet.getHostName());
System.out.println("IP Address is: " + iNet.getHostAddress());
}
提前致谢!
最佳答案
使用文本区域对象的setText()
方法。textareaobj.setText(...)