ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
299
299
EMPFEHLEN
-
Hi Leute,
hab da ein "kleines" Problem mit der FocusTraversalPolicy Klasse. Hab eine selbst abgeleitete JComboBox in meinem Panel:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
/** * */ package com.ed.Tools; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.util.Vector; import javax.swing.ComboBoxEditor; import javax.swing.ComboBoxModel; import javax.swing.JComboBox; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.JTextComponent; /** * Combobox welche die Listelemente anhand der Eingabe filtert * * @author dreyer * */ public class ComboBoxWithSearch extends JComboBox { private static final long serialVersionUID = 1L; public ComboBoxWithSearch() { super(); init(); } public ComboBoxWithSearch(ComboBoxModel arg0) { super(arg0); init(); } public ComboBoxWithSearch(Object[] arg0) { super(new AutoFilteringComboBoxModel(arg0)); init(); } public ComboBoxWithSearch(Vector<?> arg0) { super(new AutoFilteringComboBoxModel(arg0.toArray())); init(); } private void init() { setEditable(true); final ComboBoxEditor edi = getEditor(); final JTextComponent ediComp = (JTextComponent) edi .getEditorComponent(); ediComp.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { Object quelle = e.getSource(); if (quelle instanceof JTextComponent) { ((JTextComponent) quelle).setCaretPosition(0); } } @Override public void focusGained(FocusEvent e) { Object quelle = e.getSource(); if (quelle instanceof JTextComponent) { ((JTextComponent) quelle).selectAll(); } } }); ediComp.getDocument().addDocumentListener(new DocumentListener() { private synchronized void setSelectedItem() { SwingUtilities.invokeLater(new Runnable() { public synchronized void run() { if ((edi.getItem() instanceof String) && ComboBoxWithSearch.this.isVisible()) try { setPopupVisible(true); } catch (Exception e) { // Do nothing } final int oldItemCount = getItemCount(); ComboBoxWithSearch.this.setSelectedItem(edi.getItem()); final int newItemCount = getItemCount(); final int maxRowCount = getMaximumRowCount(); if (isPopupVisible() && oldItemCount != newItemCount && Math.min(oldItemCount, newItemCount) < maxRowCount) { setMaximumRowCount(1); setMaximumRowCount(maxRowCount); } ediComp.setCaretPosition(ediComp.getText().length()); } }); } public void changedUpdate(DocumentEvent e) { setSelectedItem(); } public void insertUpdate(DocumentEvent e) { setSelectedItem(); } public void removeUpdate(DocumentEvent e) { setSelectedItem(); } }); } }
Und zwar bekomme ich als Component Parameter wenn ich per Tab in die nächste Componente wechsle in der Methode
anstatt die ComboBoxWithSearch den BasicComboBoxEditor geliefert, was kann ich da machen?Code :1 2
public Component getComponentAfter(Container aContainer, Component aComponent)
Zudem hat sich gerade heraus gestellt, dass falls jemand die API kennt:
JCalendar Java Bean, a Java Date Chooser
beim Focus in den JDateChooser der Focus nicht richtig gesetzt wird bzw. ich das TextFeld nicht bearbeiten kann, jedoch weiter in die nächsten Componenten korrekt beim Tab gesprungen wird
Gruß JanGeändert von ElJarno (04.11.10 um 12:10 Uhr)
Ähnliche Themen
-
[IE7 Problem] Problem mit ul/li Höhen im IE7 bei Verwendung eines vertikalen Menüs
Von josDesign im Forum CSSAntworten: 0Letzter Beitrag: 11.01.11, 21:40 -
FocusTraversalPolicy
Von darksmilie im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 2Letzter Beitrag: 18.12.06, 16:07 -
Problem: Flash MX (7.1) exportiert meine Fla nicht mehr - dringendes Problem
Von Lukasz im Forum Flash PlattformAntworten: 4Letzter Beitrag: 22.03.06, 20:50 -
Problem mit hover- background ändern & Problem bei Reload
Von ollioollio im Forum CSSAntworten: 0Letzter Beitrag: 06.10.04, 14:03 -
Problem mit PopUp (Ja ich weiss Suche benutzten, hab ein ganz anderes Problem)
Von killkrog im Forum Javascript & AjaxAntworten: 6Letzter Beitrag: 13.06.02, 12:29





Zitieren
Login





