1. LuisM Pena
  2. tablefilter-swing
  3. Issues

Issues

Issue #39 resolved

Wrong filter value when AutoChoices is enabled

Antoine Guillou
created an issue

Hey Luis, Thanks for your great filter!

I noticed a problem when filtering a column which has:

  • values of class double, but in fact all are integers values ( Double(1), Double(2), ... ).

  • AutoChoices.ENABLED

In the example above, filtered the column "Double" with ">=3" and click anywhere in the table. Then the filter value become "5"....

    public static void main(String args[]) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Object rowData[][] = { { "Str1" , true, new Double(1) },
                { "Str2" , true, new Double(2) },
                { "Str3" , false, new Double(3) },
                { "Str4" , true, new Double(4) },
                { "Str5" , false, new Double(5) } };
        Object columnNames[] = { "String", "BOO", "Double" };


        DefaultTableModel model = new DefaultTableModel(rowData, columnNames);

        JTable table = new JTable(model);

        ExtendedCoderazziFilter jFilter_RunsTable = new com.meta.coderazziextension.ExtendedCoderazziFilter( table, net.coderazzi.filters.gui.AutoChoices.DISABLED);

        jFilter_RunsTable.getFilterEditor( 2 ).setAutoChoices( net.coderazzi.filters.gui.AutoChoices.ENABLED );

        JScrollPane scrollPane = new JScrollPane(table);
        frame.add(scrollPane, BorderLayout.CENTER);
        frame.setSize(300, 150);
        frame.setVisible(true);

    }

Comments (8)

  1. LuisM Pena repo owner

    Hi, Antoine, thanks for submitting the issue; I am using a slightly different code that makes no usage of your ExtendedCoderazziFilter.

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import net.coderazzi.filters.*;
    import net.coderazzi.filters.gui.*;
    
    public class Issue_39 {
        public static void main(String args[]) {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            Object rowData[][] = { { "Str1" , true, new Double(1) },
                    { "Str2" , true, new Double(2) },
                    { "Str3" , false, new Double(3) },
                    { "Str4" , true, new Double(4) },
                    { "Str5" , false, new Double(5) } };
            Object columnNames[] = { "String", "BOO", "Double" };
    
    
            DefaultTableModel model = new DefaultTableModel(rowData, columnNames);
    
            JTable table = new JTable(model);
    
            TableFilterHeader jFilter_RunsTable = new TableFilterHeader( table, net.coderazzi.filters.gui.AutoChoices.DISABLED);
    
            jFilter_RunsTable.getFilterEditor( 2 ).setAutoChoices( net.coderazzi.filters.gui.AutoChoices.ENABLED );
    
            JScrollPane scrollPane = new JScrollPane(table);
            frame.add(scrollPane, BorderLayout.CENTER);
            frame.setSize(300, 150);
            frame.setVisible(true);
    
        }
    }
    

    It still shows the same error you report...

  2. Log in to comment