我想在用戶卸載我的應用程序(獨立Java應用程序)之前向用戶顯示彈出窗口,如果他想刪除某些文件。在卸載Java桌面應用程序之前顯示彈出窗口
我搜索了一個解決方案,但我只找到了一些對我無用的android解決方案。
我需要一個純java解決方案,或者我需要知道,如果有另一種方法來做到這一點。
我想在用戶卸載我的應用程序(獨立Java應用程序)之前向用戶顯示彈出窗口,如果他想刪除某些文件。在卸載Java桌面應用程序之前顯示彈出窗口
我搜索了一個解決方案,但我只找到了一些對我無用的android解決方案。
我需要一個純java解決方案,或者我需要知道,如果有另一種方法來做到這一點。
JOptionPane可以很容易地彈出提示 用戶提供值或通知的東西他們一個標準的對話框。
JOptionPane的showConfirmDialog()詢問確認問題,如yes/no/cancel。 Visit a sample tutorial here它演示瞭如何使用它。
一個樣本實施例: -
// f = new File(filePath);
// filePath is of type String and stores location of the file.
int dialogButton=JOptionPane.YES_NO_OPTION;
int dialogResult=JOptionPane.showConfirmDialog(null,"Would you like to uninstall this application(Press Yes to delete OR No to quit)???","Confirm Action", dialogButton);
if(dialogResult==JOptionPane.YES_OPTION)
f.delete();
else
{
FinalLabel.setText("File Uninstallation process cancelled...");
try {
Thread.currentThread().wait(2000);
} catch (InterruptedException ex) {
System.exit(0);
}
}
所以,您可以嘗試在獨立Java應用程序使用此。
您可能需要尋找一些安裝程序並執行一些R & D以及像Wix這樣可以幫助您爲應用程序創建安裝程序。
Addtionally如果你提醒安裝和卸載,請參考此鏈接Wix install/uninstall prompt用戶,這也Wix custom action uninstall
你能發佈您的代碼? –
哪種桌面應用程序? Swing,JavaFx,... WebStart與否... – Stefan
@ StefanLindenberg-我非常懷疑webstart是否符合桌面應用程序,OP不希望瀏覽器或互聯網運行從問題中清楚的應用程序(卸載/刪除我的申請)。 –