java - Refresh JComboBox with SwingX AutoCompleteDecorator -
I am using SwingX AutoCompleteDecorator on a JComboBox. Everything works fine, I want to allow my user to change the name of my object, the name also appears in the combo box. The problem is that I can refresh myself, but as shown in the picture remains the string displayed by the autocomplete decorator:
The code looks like this to refresh the combobox:
try {Aannemer a = getNewAannemer (); MainController.getInstance () updateAannemer (a). AannemerBox.revalidate (); AannemerBox.repaint (); } Hold (Exception Pre) {//}} String Update When I search with Object ComboBox again I also use a personal renderer and editor for Cambodia. Tried Any ideas how can I refresh the string shown as shown?
After the
With the current code, it is difficult to say what is going wrong. The following code works fine for me
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; Import javax.swing.DefaultComboBoxModel; Import javax.swing.JButton; Import javax.swing.JComboBox; Import javax.swing.JFrame; Import javax.swing.WindowConstants; Import java.awt.borderLayout; Import java.awt.EventQueue; [Public square AutoCompleteCombobox {public static void (String] args) {EventQueue.invokeLater (() - & gt; {JFrame frame = new JFrame ( "TestFrame"); JComboBox & LT; string & gt; was telling = new JComboBox & lt; & gt; (); DefaultComboBoxModel & LT; string & gt; model = new DefaultComboBoxModel & lt; & gt; (); model.addElement ( "first"); model.addElement ( "second"); comboBox. SetModel (model); comboBox.setEditable (right); AutoCompleteDecorator.decorate (say was); frame.getContentPane (.) add (tell was); JButton button = new JButton ( "Add item"); button.addActionListener (e - & gt; {string SelectedItem = (string) comboBox.getSelectedItem (); if (tell the .getSelectedIndex () == -1) {model.addElement (SelectedItem);}}) ;. fr AmekgetContentPane (add) (buttons, BorderLayout.SOUTH); frame.pack (); frame.setVisible (right) frames KsetDefaultCloseOperation (wind OwConstants.EXIT_ON_CLOSE);}); Autocomplete works as expected I can input new items When using the add button, I can add new Items and autocomplete behave well In short, I can not reproduce your problem. Please post a piece of code in your question, Allows to generate
Comments
Post a Comment