5. Februar 200322 j Mit "JOptionPane.showInputDialog(...);" bekomme ich ein JOptionPane mit einer JComboBox (wenn ich dafür im Konstruktor ein Array zur Verfügung stelle) und zwei JButtons (Cancel, OK). Wie bekomme ich es hin, dass diese ComboBox editierbar wird ?
5. Februar 200322 j JComboBox box = new JComboBox(); box.setEditable(true); sagt mal die java-hilfe http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JComboBox.html greetz bigredeyes
6. Februar 200322 j Für eine einfache JComboBox weiß ich das auch dass das so geht. Darum gehts aber nicht. Denn nur, wenn du mir jetzt noch erzählst, wie ich die im JOptionPane eingebettete JComboBox anspreche, wäre ich glücklich.
6. Februar 200322 j Hi, du könntest dir alle componenten der JOptionPane mit getComponents() geben lassen. Das Component[] durchläufst du dann und schaust, of die aktuelle Componente instanceof JComboBox ist und castest die Componente dann zu JComboBox. Gruß Jaraz
6. Februar 200322 j Du meinst so: JOptionPane jop = new JOptionPane(Vectorinhalt); Component[] c = jop.getComponents(); for (int i =0; i < c.length; i++) { if (((Component)c) instanceof JComboBox) { JComboBox combo =(JComboBox)c; combo.setEditable(true); } } Hatte ich schon versucht. Es werden lediglich 2 JPanel gefunden, die wiederum Componenten enthalten usw. Im Debugger habe ich aber keine JComboBox ausfindig machen können.
6. Februar 200322 j Hi, dann weiss ich auch nicht weiter. Musste dir notfalls was eigenes basteln. Gruß Jaraz
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.