Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
事情是这样的:我正在对数据库进行一些输入。插入行后,我想显示一个对话框,上面写着“数据已输入数据库。您要将其导出到 Excel 吗?”
我知道连接到 Excel 的代码。问题是我想单击对话框中的“是”按钮将数据输入到 Excel 中。
如何添加对对话框执行的操作?我试过这个网站,但它不工作。
就这样吗?
int reply = JOptionPane.showConfirmDialog(null, "Would you like to export to Excel?", "Export", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { //Excel Logic } else { //Not Excel Logic }