在我的程序的一部分中,我使用a JOptionPane来询问用户他们是否确定他将做什么.但是我不想让用户每次尝试都要求这样我喜欢使用android中的一些对话框的功能,这些对话框带有"不要再问",但不知道如何在我的程序中实现它,有人在这里你可以帮助我吗?(应该有一个西班牙语StackOverflow)这是我的代码
if (jCheckBox2.isSelected() && jCheckBox1.isSelected()){
JOptionPane.showConfirmDialog(null, "This action can cause problems, want to do it?");
//here must be something to never ask again this
}
Run Code Online (Sandbox Code Playgroud) 我试图在 JOptionPane 中放置一个 Gif 图像来模拟“加载”,但没有结果。我尝试使用 URL、本地图像和图像的绝对路径,但我只能在其中放置图像(png、jpg...)。我最后一次尝试是这样
final ImageIcon icon = new ImageIcon(new URL("http://www.archisevilla.org/wp-content/themes/archisevilla/images/loading.gif"));
JOptionPane.showMessageDialog(null, "Cerrando sesión...", "About", JOptionPane.INFORMATION_MESSAGE, icon);
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,JOptionPane 图像的占位符看起来是空的。
所以我想知道:是否可以将 GIF 放在 JOptionPane 中,甚至放在 JFrame 中?
这是我正在使用的代码
private void cerrarsesion() throws Exception {
this.dispose();
String path = "/com/icono/loading.gif";
URL url = this.getClass().getResource(path);
System.out.println(url);
ImageIcon icon = new ImageIcon(url);
createTimerClose(10).start();
JOptionPane.showMessageDialog(null, "Cerrando sesión...", "About", JOptionPane.INFORMATION_MESSAGE, icon);
new Login().setVisible(true);
}
Run Code Online (Sandbox Code Playgroud)