Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:44:46+00:00 2026-06-04T11:44:46+00:00

For example in the following code i want to change the JTextField to show

  • 0

For example in the following code i want to change the JTextField to show whether the port im scanning is open or not but i dont know how to go about doing this. Maybe i need some helper methods?

public void actionPerformed(ActionEvent arg0) {
  console.setText("Starting check\n" +
    "Start = "+stopServTf.getText()+
    "\nStop ="+stopServTf.getText()+
    "\nPort Start ="+startPortTf.getText()+
    "\nPort Stop ="+stopPortTf.getText());
  PortScanner p= new PortScanner(Integer.parseInt(startPortTf.getText()),
    Integer.parseInt(stopPortTf.getText()),startServTf.getText());
}

and the other method/constructor

public   PortScanner(int portStart, int portStop ,String ip) {
  for (int i = portStart; i <= portStop; i++) {
    try {
      Socket ServerSok = new Socket(ip, i);
      setString(i);
      //System.out.println("Port in use: " + i);
      ServerSok.close();
    } catch (Exception e) {
    }
    setStrinN(i);
    System.out.println("Port not in use: " + i);
  }
}

public static String setString(int i) {
  return "Port in use: " +i;
}

public static String setStrinN(int i){
  return "Port not in use: "+i;
} 

So that I want to send to console.setText();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:44:48+00:00Added an answer on June 4, 2026 at 11:44 am

    When you are calling setString(i);, that function returns a string that you discard (i.e. do not store anywhere). You either need to store the string and retrieve it later, ot if you want to call console.setText() with that returned string, you need to pass console to the PortScanner constructor:

    public PortScanner(int portStart, int portStop, String ip, JTextArea console)
    

    and change the call to setString(i); to

    console.setText(setString(i));
    

    Furthermore (as the PortScanner constructor has changed), call

     PortScanner p= new PortScanner(Integer.parseInt(startPortTf.getText()),
       Integer.parseInt(stopPortTf.getText()),startServTf.getText()); 
    

    in actionPerformed()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following code example, I want to change the color of the Foreground
In the following code example how do the user/userParam references relate to the Customer
Please consider the following example code (from the lm doc): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt
Please forgive the verbosity of the following code example. Using Delphi 2009, I created
The following code is an example of what I think would qualify as pseudocode,
The following code sample (also at http://jsfiddle.net/MZwBS/ ) var items = []; items.push({ example:
When I execute this following code for example: cart.php?p=1&action=add <?php session_start(); if (isset($_GET['p']) &&
How do you make the following code work? example = %%(test)% % {'test':'name',} print
Say I have the following code: <div onclick='location.href=http://www.example.com/'> <a href='#' onclick='alert(blah)'>click</a> </div> Is there
On a report I have the following code for a field: =Sum([PartQty]*[ModuleQty]) Example results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.