我遇到了针对ProgressBar的setVisible的问题,我想在我的应用程序中单击一个Login按钮后显示一个进度条,该按钮也将执行登录到mysql数据库。问题是,在处理按钮点击期间,显示进度条是最后一件事。
public void handleLoginButton() {
Connection connection = null;
int wasError=0;
loadingBar.setVisible(true);
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return;
}
try {
connection = DriverManager
.getConnection("jdbc:mysql://address","USER","PASSWORD");
} catch (SQLException e) {
wasError=1;
System.out.println("Connection Failed! Check output console");
//e.printStackTrace();
return;
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
如何首先执行setVisible?