I have 2 questions:
How can I check if Internet connection is whether turned on or turned off? I'm using Html Unit and I'm working on Windows.
I want to make a JLabel that states the availability of internet connection in my JFrame. Something like:
while(true)
{
if(isOnline()) label.setText("online");
else label.setText("offline");
}
but I think I need 2 sperated threads, but how could I create these 2 threads and communicate between them and achieve this?
A similar question was answered here: how-to-check-if-internet-connection-is-present-in-java
To do the second part of your question, I suppose you could call the InetAddress.isReachable method in a java.util.Timer that is wrapped in a SwingWorker thread to periodically poll the connection.