ich hätte da mal eine Frage zur Klasse JOptionPane.
Und zwar sollte hier im Falle, das der DialogType INPUT_DROPDOWN ist, ein JOptionPane mit Dropdown - Menü erscheinen. Wenn ich diesen Code aber ausführe, bekomme ich ein Fenster, das genau wie der Standard aussieht… Kann mir jemand sagen warum?
Vielen Dank!
import javax.swing.JOptionPane;
public class KapaGui extends JOptionPane {
private String input = "";
public KapaGui(DialogType dialogType, String description) {
if (dialogType == DialogType.INPUT) {
this.input = this.showInputDialog(description);
} else if (dialogType == DialogType.INPUT_DROPDOWN) {
String[] array = new String[] { "a", "b", "c" };
this.input = (String) this.showInputDialog(null, description,
"Show Database Table", 4, null, array, "1");
} else if (dialogType == DialogType.CONFIRM) {
this.showConfirmDialog(this, initialSelectionValue);
}
}
public String getInput() {
return this.input;
}
}
MMn bringt es nichts das JOptionPane zu überschreiben, man kriegt so ziemlich alles hin wenn man auf die statischen showXXXDialog Funktionen zurückgreift. Für einfache Ein/Ausgaben reichts sowieso, für was komplexeres kann man sich einfach ein Panel zusammenbauen und das dann der Funktion übergeben. http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html