简体   繁体   中英

How Do I Get Output From My NsLookup Program into JTextArea in Seperate Program

I am just wondering how I would get the output from a seperate NsLookup program into a TextArea in my NsLookupGUI program?

I have an ActionListener;

private class buttonPressed implements ActionListener {
        public void actionPerformed(ActionEvent a) {
                getText = userInputBox.getText();

        lookup.resolve(getText);

        results.append(getText + "\n"); 
        }

to call the Nslookup class. However, the output is displayed in the terminal rather than the TextArea.

The piece of code below is my NsLookup program;

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());
    }

Thanks in advance!

使用文本区域对象的setText()方法。

textareaobj.setText(...)

如果需要,您还可以将System.out重新分配给打印到文本区域的自定义OutputStream。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM