我想在 actionlistener 中按特定顺序执行任务。在我的代码中,我希望在执行按钮上的主要任务时显示加载图标。但是当我按下 d 按钮时,一切都同时完成了。数据库连接..这是我的代码
take.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent ev){
img.setIcon(image);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
String formatted = format1.format(cal.getTime());
String dname = (String)doclist.getSelectedItem();
try{
db.connect();
rs=db.stmt.executeQuery("Select * from table4 where name='"+dname+"'");
rs.next();
final String id=rs.getString("dr_id");
String mst=rs.getString("mor_start");
String est=rs.getString("eve_start");
int mmax=rs.getInt("mor_max");
int emax=rs.getInt("eve_max");
int mava=rs.getInt("mor_ava");
int eava=rs.getInt("eve_ava");
}});