RegisterSearchFAQ UsergroupsLog in
version 4.1.51 AdvancedJTable Filtering not working

 
Reply to topic    Citra Technologies Forum Index » Report a Bug View previous topic
View next topic

version 4.1.51 AdvancedJTable Filtering not working
Author Message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post version 4.1.51 AdvancedJTable Filtering not working Reply with quote
Hi,

I created a small swing application to test filtering in commercial version 4.1.51 (com.sciapp package)
The filter combobox popup opens up but filtering does not works on selecting a value from the combobox.


Code:

FilterTableModel ftm = new FilterTableModel(model);
   SortTableModel stm = new SortTableModel(ftm);
        advancedJTable1.setModel(stm);
        stm.setHeader(advancedJTable1.getTableHeader());
   CustomPopupFilterHeaderModel fhm = new CustomPopupFilterHeaderModel();
   fhm.attachToTable(advancedJTable1, ftm);


I went back to check on the earlier version 4.1.45 , it had the same problems there
Although it seems to work on a much earlier version 4.1.19

I am blocked on this problem.

Kindly let me know how to fix it, or if you could provide me a working version earlier than version 4.1.46.

thanks
Karl
Fri Feb 27, 2015 9:36 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

I can't seem to find something wrong with our code. Please find below a sample program in which filtering works as expected, tested against the latest version, 4.1.51. (you will also need the classes from the demo source code package):

Code:
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.UIManager;

import com.sciapp.demo.PersonDataFeeder;
import com.sciapp.demo.PersonTableModel;
import com.sciapp.filter.CustomPopupFilterHeaderModel;
import com.sciapp.table.AdvancedJScrollPane;
import com.sciapp.table.AdvancedJTable;
import com.sciapp.table.FilterTableModel;
import com.sciapp.table.ListTableModel;
import com.sciapp.table.SortTableModel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;

public class Test {
   public static void main(String[] args) {
      //create table and model
      AdvancedJTable advancedJTable1 = new AdvancedJTable();
      ListTableModel model = new PersonTableModel();
      model.addRows(new PersonDataFeeder().createObjects(100));

      //your code below
      FilterTableModel ftm = new FilterTableModel(model);
      SortTableModel stm = new SortTableModel(ftm);
      advancedJTable1.setModel(stm);
      stm.setHeader(advancedJTable1.getTableHeader());
      CustomPopupFilterHeaderModel fhm = new CustomPopupFilterHeaderModel();
      fhm.attachToTable(advancedJTable1, ftm);

      show(advancedJTable1);
   }
   public static JPanel show(JTable table) {
      try {
         UIManager.setLookAndFeel(new WindowsLookAndFeel());
         table.updateUI();
         table.getTableHeader().updateUI();
      } catch (Exception e) {
         System.out.println(e);
      }
      JFrame frame = new JFrame();
      frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            System.exit(0);
         }
      });

      try {
         Container c = frame.getContentPane();
         JPanel p = new JPanel(new BorderLayout());
         p.add(new AdvancedJScrollPane(table));
         c.add(p);

         //center
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
         int width = (int) (screenSize.width * 0.75);
         int height = (int) (screenSize.height * 0.75);
         if (width <= 0) width = 700;
         if (height <= 0) height = 500;
         frame.setSize(width, height);
         Dimension d = frame.getSize();
         frame.setLocation((screenSize.width - d.width) / 2,(screenSize.height - d.height) / 2);

         //set visible
         frame.setVisible(true);

         return p;

      } catch (Throwable t) {
         System.out.println(t);
      }
      return null;
   }
}


I do not know how earlier versions give different results.
Fri Feb 27, 2015 10:13 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
Hi Again,

I tried again with the code snippet you tried and it still doesn't work on my machine. I tried with different Java versions on different machines, doesn't work.

I downloaded the latest lib from the downloads page, Could you please provide me the lib file that you used to make it run?

You could sent it to me via email if you don't want to post it here (chahat.bhatia@premotec.ch)

Also could you please provide me your email address, where i could send you the lib and the licence (jars) that i am using, for you to try out at your workstation.

Could there be another reason why it works for you and not for me?

Thanks
kpresser
Fri Feb 27, 2015 11:26 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

I sent you an e-mail with the library that was used in testing the code above. If it still does not work for you, then it might be due to the JRE version. What JRE version are you using?
Mon Mar 02, 2015 5:17 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
Hi,

thanks I have replied to you over the email.

I am using jdk1.7.0_60 but have also tried the latest JDK 1.8

thanks
kpresser
Mon Mar 02, 2015 6:40 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi again,

Please add the following lines to the code above, run the program, and post here the output after making the filter popup visible and then selecting a value of it.

Thanks

Code:
fhm.getComboBox().addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         System.out.println(e);
         System.out.println(((JComboBox) e.getSource()).isPopupVisible());
      }
   });

Mon Mar 02, 2015 9:06 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
Here you go

Code:

java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1425305895782,modifiers=] on
com.sciapp.filter.PopupFilterHeaderModel$h[,0,0,75x0,invalid,layout=com.sun.java.swing.plaf.windows.WindowsComboBoxUI$3,
alignmentX=0.0,alignmentY=0.0,border=com.sun.java.swing.plaf.windows.XPStyle$XPFillBorder@2ad15ee4,flags=328,
maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=(All)]
false
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1425305899103,modifiers=] on
com.sciapp.filter.PopupFilterHeaderModel$h[,0,18,75x0,layout=com.sun.java.swing.plaf.windows.WindowsComboBoxUI$3,
alignmentX=0.0,alignmentY=0.0,border=com.sun.java.swing.plaf.windows.XPStyle$XPFillBorder@2ad15ee4,flags=328,
maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=Hans]
true


thanks
Mon Mar 02, 2015 9:19 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
How do you select a filter value? Do you not click it with the mouse?

There seems to be a problem with the modifiers not being passed to the event.
Mon Mar 02, 2015 10:57 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
Yes I do, I click on the filter drop down button which opens a popup menu and select a value. As I said earlier the pop-up closes but nothing happens.
Mon Mar 02, 2015 11:22 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
OK I just tried selecting the filter with keyboard and the filtered worked.

Probably the mouse click event is not getting captured.
Mon Mar 02, 2015 11:26 am View user's profile Send private message
kpresser



Joined: 10 Dec 2008
Posts: 16

Post Reply with quote
When I navigate the filter list in the pop up with the key down, I get these sysout messages

Code:

java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1425313821348,modifiers=] on
com.sciapp.filter.PopupFilterHeaderModel$h[,0,18,75x0,layout=com.sun.java.swing.plaf.windows.WindowsComboBoxUI$3,
alignmentX=0.0,alignmentY=0.0,border=com.sun.java.swing.plaf.windows.XPStyle$XPFillBorder@2bb0521c,flags=328,
maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=John]
true


But I do not get these sysout messages when I hover the mouse over the filter list, although the selected list entry does change but no sysout messages are generated..
Mon Mar 02, 2015 11:32 am View user's profile Send private message
support



Joined: 21 Feb 2006
Posts: 1463

Post Reply with quote
Hi,

For some reason, the mouse event on the filter popup was not being correctly dispatched on your JVM. I do not know why this happened, however I found another way of dealing with this. You can download the new version and try it out.

Thanks
Tue Mar 03, 2015 12:42 pm View user's profile Send private message
Display posts from previous:    

Reply to topic    Citra Technologies Forum Index » Report a Bug All times are GMT - 5 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group