FileDocCategorySizeDatePackage
TableSearcherSimulator.javaAPI DocApache Lucene 1.92874Mon Feb 20 09:18:14 GMT 2006org.apache.lucene.swing.models

TableSearcherSimulator

public class TableSearcherSimulator extends Object
author
Jonathan Simon - jonathan_s_simon@yahoo.com

Fields Summary
Constructors Summary
public TableSearcherSimulator()

        JFrame frame = new JFrame();
        frame.setBounds(200,200, 400,250);

        JTable table = new JTable();
        final BaseTableModel tableModel = new BaseTableModel(DataStore.getRestaurants());
        final TableSearcher searchTableModel = new TableSearcher(tableModel);

        table.setModel(searchTableModel);
        JScrollPane scrollPane = new JScrollPane(table);

        final JTextField searchField = new JTextField();
        JButton searchButton = new JButton("Go");

        ActionListener searchListener = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
               searchTableModel.search(searchField.getText().trim().toLowerCase());
                searchField.requestFocus();
            }
        };

        searchButton.addActionListener(searchListener);
        searchField.addActionListener(searchListener);



        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(scrollPane, BorderLayout.CENTER);

        JPanel searchPanel = new JPanel();
        searchPanel.setLayout(new BorderLayout(10,10));
        searchPanel.add(searchField, BorderLayout.CENTER);
        searchPanel.add(searchButton, BorderLayout.EAST);

        JPanel topPanel = new JPanel(new BorderLayout());
        topPanel.add(searchPanel, BorderLayout.CENTER);
        topPanel.add(new JPanel(), BorderLayout.EAST);
        topPanel.add(new JPanel(), BorderLayout.WEST);
        topPanel.add(new JPanel(), BorderLayout.NORTH);
        topPanel.add(new JPanel(), BorderLayout.SOUTH);

        frame.getContentPane().add(topPanel, BorderLayout.NORTH);

        frame.setTitle("Lucene powered table searching");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.show();

    
Methods Summary
public static voidmain(java.lang.String[] args)

        new TableSearcherSimulator();