2013-07-18 53 views
0

最近,我一直在使用一個使用http基本身份驗證的Netbeans插件。所以爲了驗證密碼是否正確,我有以下代碼。連接到URL時的Netbeans平臺消息對話框

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); 

在正常的Swing應用程序前面的代碼有助於顯示,如果在引黃是好的,但是當我把它放在一個NetBeans平臺插件和連接不正常它帶給我下面的對話框。 enter image description here

如何禁用此對話框?

回答

1

你有沒有試過如下:

conn.setAllowUserInteraction(false);