Im Anschluss ist mein Swing Programmcodebestätigen Dialogfeld in Schwung mit zwei Knöpfen
import javax.swing.*;
import java.awt.event.*;
public class OptionPaneExample extends WindowAdapter{
JFrame f;
OptionPaneExample(){
f=new JFrame();
f.addWindowListener(this);
f.setSize(300, 300);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.setVisible(true);
}
public void windowClosing(WindowEvent e) {
int a=JOptionPane.showConfirmDialog(f,"Are you sure?");
if(a==JOptionPane.YES_OPTION){
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public static void main(String[] args) {
new OptionPaneExample();
}
}
In Ausgang möchte ich nur zwei Tasten Ja und Nein, aber in der Ausgabe-Taste abbrechen ich erhalte. Wie Sie das entfernen können, lassen Sie es mich wissen.
I'm getting this output. But i want only two buttons Yes and No.
Ich würde empfehlen, einen Blick auf [Wie Sie Dialoge verwenden] (https://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html) – MadProgrammer