Laf-Widget client properties

View all client properties.


Client property name

LafWidget.COMBO_BOX_NO_AUTOCOMPLETION

Description

Client property name for specifying that the editable combobox has no auto completion. This property can be set either on a single combobox or globally on UIManager. The value in both cases should be either Boolean.TRUE or Boolean.FALSE. By default, all editable comboboxes have auto-completion.


See also


Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.lafwidget.LafWidget;
import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;

/**
 * Test application that shows the use of the
 {@link LafWidget#COMBO_BOX_NO_AUTOCOMPLETION} client property.
 
 @author Kirill Grouchnikov
 @see LafWidget#COMBO_BOX_NO_AUTOCOMPLETION
 */
public class ComboBoxNoAutoCompletion extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public ComboBoxNoAutoCompletion() {
    super("Combobox no auto-completion");

    this.setLayout(new BorderLayout());

    final JComboBox cb = new JComboBox(new Object[] { "Ester""Jordi",
        "Jordina""Jorge""Sergi" });
    cb.setEditable(true);

    JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER));
    this.add(main, BorderLayout.CENTER);
    main.add(cb);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox noAutoCompletion = new JCheckBox(
        "No auto-completion");
    noAutoCompletion.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        cb.putClientProperty(LafWidget.COMBO_BOX_NO_AUTOCOMPLETION,
            noAutoCompletion.isSelected() ? Boolean.TRUE
                null);
      }
    });

    controls.add(noAutoCompletion);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new ComboBoxNoAutoCompletion().setVisible(true);
      }
    });
  }
}

The screenshot below shows an editable combo when this property is not installed. On typing "J", the "Jordi" entry is selected:

After this property has been installed, pressing "J" does not select any entry and does not show the popup: