0
我在方法(private void jButton2ActionPerformed
)中创建了类DownloadManager
的实例,并且需要通过另一种方法访问它?如何用不同的方法创建一个类的实例?
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
//need to access the instance dman here
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
DownloadManager dman = new DownloadManager();
dman.actionAdd("http://dev.x-plane.com/download/tools/wed_mac_141r1.zip");
dman.actionAdd("http://dev.x-plane.com/download/tools/wed_mac_141r1.zip");
dman.setVisible(true);
}
也许看看单身模式?可以使用一个类级别的实例? – MadProgrammer
如果您需要其他方法中的DownloadManager对象,请在此处定义。我看到你不在jButton2ActionPerformed方法中使用它。 –