Yes, your results are exactly what I was expecting. On Thu, Oct 18, 2018 at 4:35 PM, Laurent Bourgès <bourges.laur...@gmail.com> wrote:
> Hi Martin, > > Here are my test outputs: > > 1/ First > $ java TestWinEvent > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.RepaintManager$ProcessingRunnable@28985415, > notifier=null,catchExceptions=false,when=1539872732255] on > sun.awt.X11.XToolkit@4645926f > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.Timer$DoPostEvent@1a954cb5, > notifier=null,catchExceptions=false,when=1539872733214] on > sun.awt.X11.XToolkit@4645926f > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.RepaintManager$ProcessingRunnable@1208f81d, > notifier=null,catchExceptions=false,when=1539872733286] on > sun.awt.X11.XToolkit@4645926f > reject ID = 1100 : java.awt.event.InputMethodEvent[INPUT_METHOD_TEXT_CHANGED, > no text, 0 characters committed, no caret, no visible position] on > javax.swing.JButton[,0,51,300x25,invalid,alignmentX=0.0, > alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$ > CompoundBorderUIResource@75806c8,flags=296,maximumSize= > ,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=, > disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left= > 14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=, > rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=TEST > 2,defaultCapable=true] > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.Timer$DoPostEvent@1a6b3cd6, > notifier=null,catchExceptions=false,when=1539872733215] on > sun.awt.X11.XToolkit@4645926f > java.lang.IllegalStateException: Total [4] != expected [400] ! > at TestWinEvent.main(TestWinEvent.java:53) > > *java.lang.IllegalStateException: Total [4] != expected [400] !* > > $ java TestSeqEventsMultipleContexts > java TestSeqEventsMultipleContexts > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.RepaintManager$ProcessingRunnable@6d620f31, > notifier=null,catchExceptions=false,when=1539872801695] on > sun.awt.X11.XToolkit@65746729 > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.Timer$DoPostEvent@2bfb82e8, > notifier=null,catchExceptions=false,when=1539872801890] on > sun.awt.X11.XToolkit@65746729 > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.RepaintManager$ProcessingRunnable@754b4fe7, > notifier=null,catchExceptions=false,when=1539872801894] on > sun.awt.X11.XToolkit@65746729 > reject ID = 1100 : java.awt.event.InputMethodEvent[INPUT_METHOD_TEXT_CHANGED, > no text, 0 characters committed, no caret, no visible position] on > javax.swing.JButton[,0,51,300x25,invalid,alignmentX=0.0, > alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$ > CompoundBorderUIResource@51861d7a,flags=296,maximumSize=,minimumSize=, > preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin= > javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14], > paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true, > rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=TEST > 4,defaultCapable=true] > reject ID = 1200 : java.awt.event.InvocationEvent[INVOCATION_ > DEFAULT,runnable=javax.swing.Timer$DoPostEvent@e20778b, > notifier=null,catchExceptions=false,when=1539872801893] on > sun.awt.X11.XToolkit@65746729 > > *Total [8] - Expected [400]Test FAILED* > > So the TestSeqEventsMultipleContexts is failing now: > InvocationEvent must be dispatched as the test uses a Timer() to post 1 > event at a time (and avoid polluting the event queue in contrary to the > initial TestWinEvent). > > 2/ Dispatch InvocationEvents: > > > $ java TestWinEvent > reject ID = 1100 : java.awt.event.InputMethodEvent[INPUT_METHOD_TEXT_CHANGED, > no text, 0 characters committed, no caret, no visible position] on > javax.swing.JButton[,0,51,300x25,alignmentX=0.0, > alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$ > CompoundBorderUIResource@25550fd7,flags=296,maximumSize=,minimumSize=, > preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin= > javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14], > paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true, > rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=TEST > 45,defaultCapable=true] > reject ID = 103 : java.awt.event.ComponentEvent[COMPONENT_HIDDEN] on > frame0 > > $ java TestSeqEventsMultipleContexts > reject ID = 1100 : java.awt.event.InputMethodEvent[INPUT_METHOD_TEXT_CHANGED, > no text, 0 characters committed, no caret, no visible position] on > javax.swing.JButton[,0,51,300x25,alignmentX=0.0, > alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$ > CompoundBorderUIResource@70122df1,flags=296,maximumSize=,minimumSize=, > preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin= > javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14], > paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true, > rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=TEST > 17,defaultCapable=true] > > *Total [400] - Expected [400]Test PASSED* > > Here is my last hack: > private static final class SequencedEventsFilter implements > EventFilter { > private final SequencedEvent currentSequencedEvent; > private SequencedEventsFilter(SequencedEvent > currentSequencedEvent) { > this.currentSequencedEvent = currentSequencedEvent; > } > @Override > public FilterAction acceptEvent(AWTEvent ev) { > if (ev.getID() == ID) { > // Move forward dispatching only if the event is previous > // in SequencedEvent.list. Otherwise, hold it for > reposting later. > synchronized (SequencedEvent.class) { > for (SequencedEvent iev : list) { > if (iev.equals(currentSequencedEvent)) { > break; > } else if (iev.equals(ev)) { > return FilterAction.ACCEPT; > } > } > } > currentSequencedEvent.pendingEvents.add(ev); > return FilterAction.REJECT; > > > > > > > > *// LAURENT HACK << } else if (ev.getID() == > SentEvent.ID || ev.getID() == > java.awt.event.InvocationEvent.INVOCATION_DEFAULT) { return > FilterAction.ACCEPT; }System.out.println("reject ID = "+ > ev.getID() + " : " + ev.toString()); return > FilterAction.REJECT;// LAURENT HACK >>* > // return FilterAction.ACCEPT; > } > } > > I will then test on Mac ... > > Laurent >