Java Search Box

0

I'm creating a system in Java using NetBeans. I would like to create a search box that shows the results in a list (of variable size) under the box as the user enters the text to be searched. It would be something similar to the Google search box, which shows suggestions as the user is typing.

The system should also allow the user to select search results without the other results being hidden. I would like the results list to stay on other interface components.

I would also like to be able to search from certain cells in a table and have the results displayed underneath the cell used for searching.

I do not know of any component of the Swing class or NetBeans functionality that can do this. Anyone have any ideas?

    
asked by anonymous 27.12.2016 / 19:15

1 answer

2

What I found closest to this was the use of SwingX to decorate a JComboBox .

AutoCompleteDecorator.decorate(combobox);

Example:

 public class ExemploCombo {

    JFrame frame = new JFrame("");
    AutoCompleteDecorator decorator;
    JComboBox combobox;

    public ExemploCombo() {
        combobox = new JComboBox(new Object[]{"","Diego", "Bruno",
        "Bianca", "Fernando", "Davi"});
        AutoCompleteDecorator.decorate(combobox);
        frame.setSize(400,400);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout());

        frame.add(combobox);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        ExemploCombo d = new ExemploCombo();
    }
}

Source: link

    
27.12.2016 / 19:53