Nestor Hernandez Loli
Nestor Hernandez Loli

Reputation: 1442

Netbeans platform message dialog while connecting to URL

Recently I have been working with a Netbeans plugin that makes a http basic authentication. So in order to verify that the password is correct I have the following code.

String url = "http://someurl.com";
URLConnection conn = (new URL(url)).openConnection();
HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setUseCaches(false);
String input = username.getText() + ":" + password.getText();
String output = Base64.encode(input.getBytes());
hconn.setRequestProperty("Authorization", "Basic " + output);
hconn.connect();
int code = hconn.getResponseCode();
boolean connectionOk = (code == HttpURLConnection.HTTP_OK);

In a normal swing application the previous code helps to show if the connetion is ok, but when I put it in a Netbeans platform plugin and the connection is not ok it brings me the following dialog. enter image description here

What can I do to disable this dialog?

Upvotes: 0

Views: 109

Answers (1)

Sergei Ivanov
Sergei Ivanov

Reputation: 11

Have you tried the following:

conn.setAllowUserInteraction(false);

Upvotes: 1

Related Questions