This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Even though you may be starting a process from a JButton, the real question involves ping/networking, so I'm moving it to the "Sockets and Network Protocols" forum. If you're really asking about "ping" (ICMP) - there's an easy way to do it in JDK 1.5+. However, "ping" doesn't have a concept of ports, so I'm not sure what the "I don't know how to read ports from the system" part means.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
The problem with trying to use a standard ping program to see if a machine will respond is that many machines and networks simply drop these sorts of requests so no response could mean various things.
There are other ways to find out if a machine is running at an IP address. NMAP, Nessus can certainly do it, I have found that if NMAP or Nessus can't return any results at all, nothing will.
The most straightforward way in Java to test whether a port is open(which I am assuming that is what you meant) is to try to connect to port number with a TCP socket and also try sending a UDP datagram to it and see what if anything happens. To control this via a JButton, simply start the object that runs this simple port scanner with the button's listener.
You could also write a program to send a single ACK, SYN, or FIN packet to all possible ports and see if any are open, though if they are all stealthed you won't learn anything useful. A traceroute program that is a little sneaky and uses UDP, ACK, SYN, or FIN sometimes gets through networks that drop ICMP traffic. They won't respond to ICMP based traceroute but are happy to send back a time exceeded ICMP message for TCP or UDP traffic.
These last two can't be done with only the Java API, you need to either write your own JNI wrapper around libpcap or use existing ones like Jpcap and jpcap.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra