I'm trying to scan my IP for open ports and print the open ports into the gui ive created , I'm managed to get to the GUI to pop up everytime the program is ran but every time it still seems to still print out in the netbeans console and not my GUI , the code I have at the moment is as follows :
import java.io.; import java.net.; import javax.swing.*;
public class Scanner { private static Object jTextField1;
public static void main(String[] args) throws Exception { String host = "MY IP"; InetAddress ipAddress = InetAddress.getByName(host); GUI2 GUI = new GUI2(); GUI.setVisible(true); String hostName = "MY IP"; for (int port = 0; port <= 65535; port++){ try { Socket socket = new Socket (hostName, port ); String listen = hostName + "is listening on port" + port ; //System.out.println(listen); socket.close(); }catch (IOException e) { String ignore = hostName + "is not listening on port " + port; jTextField1.setText(ignore); //System.out.println(ignore); } } } }