How to prevent editCellAt being called twice extending JTable and using ITunesTableUI?

47 views
Skip to first unread message

Hugo Martinez

unread,
Oct 21, 2009, 10:52:55 PM10/21/09
to Mac Widgets for Java
HI Again,

I followed your previous recommendations about using ITunesTableUI,
instead of macwidgetFactory
to decorate my custom JTable, but I'm having other problem, Now my
editCellAt method
is being called once, but it is strange because if I use
ITunesTableUI editCellAt I found this method being called
twice!!!! :O

if I remove or comment the following lines:

ITunesTableUI tableUI = new ITunesTableUI();
tableUI.installUI(table);

It works as I expect, do you have any idea about what I'm doing wrong?

Here is my code:

package test;

import java.awt.HeadlessException;
import java.util.Date;
import java.util.EventObject;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import com.explodingpixels.macwidgets.plaf.ITunesTableUI;

public class TestTable extends JFrame {
private static final long serialVersionUID = -3031386155167714348L;
public TestTable() throws HeadlessException {
JTable table = new JTable(new Object[][] {
{ "Hugo", "Martinez", new Date() },
{ "Daniel", "Rojas", new Date() },
{ "Cesar", "Bono", new Date() } }, new Object[] { "Grupo A",
"Grupo B", "Grupo C" }) {

private static final long serialVersionUID = 2999403948795489928L;

public boolean editCellAt(int row, int column, EventObject e) {
System.out.println("editarCeldaEn(" + row + "):"
+ isCellSelected(row, column));
return false;
}
};
ITunesTableUI tableUI = new ITunesTableUI();
tableUI.installUI(table);
setContentPane(new JScrollPane(table));
}

public static void main(String[] args) {
JFrame app = new TestTable();
app.pack();
app.setVisible(true);
}
}


I appreciate your help in advance
-Hugo

Ken Orr

unread,
Oct 22, 2009, 8:09:00 AM10/22/09
to mac-widget...@googlegroups.com
Hmmm... not sure off the top of my head. If you have a debugger, can you send me the stack of each call to editCellAt (I want to see where the editCellAt call is originating from).

Thanks,
-Ken

Hugo Martinez

unread,
Oct 22, 2009, 3:19:38 PM10/22/09
to Mac Widgets for Java
Sure Ken,

This is the trace I got in the first invocation

Thread [AWT-EventQueue-0] (Suspended (breakpoint at line 42 in
TestTable$1))
TestTable$1.editCellAt(int, int, EventObject) line: 42
BasicTableUI$Handler.adjustSelection(MouseEvent) line: 1084
BasicTableUI$Handler.mousePressed(MouseEvent) line: 1014
AWTEventMulticaster.mousePressed(MouseEvent) line: 263
AWTEventMulticaster.mousePressed(MouseEvent) line: 262
TestTable$1(Component).processMouseEvent(MouseEvent) line: 6213
TestTable$1(JComponent).processMouseEvent(MouseEvent) line: 3265
TestTable$1(Component).processEvent(AWTEvent) line: 5981
TestTable$1(Container).processEvent(AWTEvent) line: 2041
TestTable$1(Component).dispatchEventImpl(AWTEvent) line: 4583
TestTable$1(Container).dispatchEventImpl(AWTEvent) line: 2099
TestTable$1(Component).dispatchEvent(AWTEvent) line: 4413
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent)
line: 4556
LightweightDispatcher.processMouseEvent(MouseEvent) line: 4217
LightweightDispatcher.dispatchEvent(AWTEvent) line: 4150
TestTable(Container).dispatchEventImpl(AWTEvent) line: 2085
TestTable(Window).dispatchEventImpl(AWTEvent) line: 2475
TestTable(Component).dispatchEvent(AWTEvent) line: 4413
EventQueue.dispatchEvent(AWTEvent) line: 599
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional,
EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional,
Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122

This is the trace I got in the 2nd invocation

Thread [AWT-EventQueue-0] (Suspended (breakpoint at line 42 in
TestTable$1))
TestTable$1.editCellAt(int, int, EventObject) line: 42
BasicTableUI$Handler.adjustSelection(MouseEvent) line: 1084
BasicTableUI$Handler.mousePressed(MouseEvent) line: 1014
AWTEventMulticaster.mousePressed(MouseEvent) line: 263
TestTable$1(Component).processMouseEvent(MouseEvent) line: 6213
TestTable$1(JComponent).processMouseEvent(MouseEvent) line: 3265
TestTable$1(Component).processEvent(AWTEvent) line: 5981
TestTable$1(Container).processEvent(AWTEvent) line: 2041
TestTable$1(Component).dispatchEventImpl(AWTEvent) line: 4583
TestTable$1(Container).dispatchEventImpl(AWTEvent) line: 2099
TestTable$1(Component).dispatchEvent(AWTEvent) line: 4413
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent)
line: 4556
LightweightDispatcher.processMouseEvent(MouseEvent) line: 4217
LightweightDispatcher.dispatchEvent(AWTEvent) line: 4150
TestTable(Container).dispatchEventImpl(AWTEvent) line: 2085
TestTable(Window).dispatchEventImpl(AWTEvent) line: 2475
TestTable(Component).dispatchEvent(AWTEvent) line: 4413
EventQueue.dispatchEvent(AWTEvent) line: 599
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional,
EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional,
Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122


That's the trace I got removing the ITunesUI

// ITunesTableUI tableUI = new ITunesTableUI();
// tableUI.installUI(table);

Thread [AWT-EventQueue-0] (Suspended (breakpoint at line 42 in
TestTable$1))
TestTable$1.editCellAt(int, int, EventObject) line: 42
BasicTableUI$Handler.adjustSelection(MouseEvent) line: 1084
BasicTableUI$Handler.mousePressed(MouseEvent) line: 1014
AWTEventMulticaster.mousePressed(MouseEvent) line: 263
TestTable$1(Component).processMouseEvent(MouseEvent) line: 6213
TestTable$1(JComponent).processMouseEvent(MouseEvent) line: 3265
TestTable$1(Component).processEvent(AWTEvent) line: 5981
TestTable$1(Container).processEvent(AWTEvent) line: 2041
TestTable$1(Component).dispatchEventImpl(AWTEvent) line: 4583
TestTable$1(Container).dispatchEventImpl(AWTEvent) line: 2099
TestTable$1(Component).dispatchEvent(AWTEvent) line: 4413
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent)
line: 4556
LightweightDispatcher.processMouseEvent(MouseEvent) line: 4217
LightweightDispatcher.dispatchEvent(AWTEvent) line: 4150
TestTable(Container).dispatchEventImpl(AWTEvent) line: 2085
TestTable(Window).dispatchEventImpl(AWTEvent) line: 2475
TestTable(Component).dispatchEvent(AWTEvent) line: 4413
EventQueue.dispatchEvent(AWTEvent) line: 599
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional,
EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional,
Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122

digging into the debug stack, I found that it's firing one additional
mousePressed Event as follows:
AWTEventMulticaster.mousePressed(MouseEvent) line: 262

I don't know why this is happening may be I should find other way???

Thank You,
Hugo Martinez

On 22 oct, 07:09, Ken Orr <kenneth....@gmail.com> wrote:
> Hmmm... not sure off the top of my head. If you have a debugger, can you
> send me the stack of each call to editCellAt (I want to see where the
> editCellAt call is originating from).
> Thanks,
> -Ken
>

Ken Orr

unread,
Oct 22, 2009, 4:08:18 PM10/22/09
to mac-widget...@googlegroups.com
Thanks Hugo. I wonder where that additional mousePressed event is coming from?
Reply all
Reply to author
Forward
0 new messages