Skip to main content

JXTable doesn't allow editing over webstart

14 replies [Last post]
boomah
Offline
Joined: 2007-07-13

Hi all.

If I have a basic web start application that displays a JTable, I can edit the JTable.

However, if I switch it out so it's exactly the same but use a JXTable instead, I cannot edit the JXTable when loaded over webstart.

If I don't use webstart, both versions work exactly the same.

I found this thread:

http://forums.java.net/jive/thread.jspa?messageID=274964&#274964

with this workaround:

jxTable.setDefaultEditor(Object.class, new DefaultCellEditor(new JTextField()));

and now it does work as expected.

So this is fine for me. Just wanted to let you people know of the problem.

Thanks...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kleopatra
Offline
Joined: 2003-06-11

Nick,

one last thing I would like you to check: can you patch one of the JXTable's in your context to create the editor directly in createDefaultEditors and verify that the problem is gone then? If it is, I'll replace the lazy creation by the direct one.

[code]

@Override
protected void createDefaultEditors() {
defaultEditorsByColumnClass = new UIDefaults(3, 0.75f);
defaultEditorsByColumnClass.put(Object.class, new GenericEditor());
defaultEditorsByColumnClass.put(Number.class, new NumberEditorExt(true));
defaultEditorsByColumnClass.put(Boolean.class, new BooleanEditor());

}

[/code]

Thanks
Jeanette

boomah
Offline
Joined: 2007-07-13

Hi.

Yes, overriding the createDefaultEditors with your code does solve the problem.

Thanks, Nick.

kleopatra
Offline
Joined: 2003-06-11

okay, raised an issue

https://swingx.dev.java.net/issues/show_bug.cgi?id=1363

Thanks
Jeanette

kleopatra
Offline
Joined: 2003-06-11

> okay, raised an issue
>
> https://swingx.dev.java.net/issues/show_bug.cgi?id=136
> 3
>

and fixed (as of revision #3864)

Cheers
Jeanette

boomah
Offline
Joined: 2007-07-13

Well I'm stumped.

Even when I strip my app as bare as I can go I still see the behaviour seen above.

I even attached a debugger to my webstart application to see where it is going wrong.

My code says that the cell is editable but then in JTable in the editCellAt method, it returns false.

[code]public boolean editCellAt(int row, int column, EventObject e){
if (cellEditor != null && !cellEditor.stopCellEditing()) {
return false;
}

if (row < 0 || row >= getRowCount() ||
column < 0 || column >= getColumnCount()) {
return false;
}

if (!isCellEditable(row, column))
return false;

if (editorRemover == null) {
KeyboardFocusManager fm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
editorRemover = new CellEditorRemover(fm);
fm.addPropertyChangeListener("permanentFocusOwner", editorRemover);
}

TableCellEditor editor = getCellEditor(row, column);
if (editor != null && editor.isCellEditable(e)) { <---- this condition is never fullfilled
editorComp = prepareEditor(editor, row, column);
if (editorComp == null) {
removeEditor();
return false;
}
editorComp.setBounds(getCellRect(row, column, false));
add(editorComp);
editorComp.validate();
editorComp.repaint();

setCellEditor(editor);
setEditingRow(row);
setEditingColumn(column);
editor.addCellEditorListener(this);

return true;
}
return false;
}[/code]

As I said before, it works with a standard JTable and when I don't launch from webstart, but not with a JXTable over webstart.

Sorry I couldn't get to the bottom of it but I need to move on now as the workaround works.

The only think I can think of is I'm doing something with class loaders (which I couldn't quickly take out) and that might be causing problems.

Thanks...[b][/b]

Message was edited by: boomah

edited to better fit the width (hate to scroll horizontally :-)

Message was edited by: kleopatra

kleopatra
Offline
Joined: 2003-06-11

weird - and just (not that I could read anything into the answer ;-) curious: which part of the condition isn't fullfilled? The editor != null or returning notEditable?

CU
Jeanette

BTW, you can format code by taggin it with [ code ] .... [ /code ] - without the spaces. Please complain to the site admin that this isn't documented anywhere ;-)

boomah
Offline
Joined: 2007-07-13

I couldn't really tell as I wasn't using a debug standard library but from stepping into where it was created, I think editor was null. That's just an educated guess though.

Thanks, Nick.

kleopatra
Offline
Joined: 2003-06-11

hmm ... could you add a simple getCellEditor(0,0) - assuming cell (0,0) would default to the plain editor for Object class - and see if it's null? If you see a problem, others probably would as well in similar contexts, so I would love to track it down (and fix) It's a long shot - but it might be that the creation of the editor fails in your context. That's done in createDefaultEditors via a LazyAction:

[code]

// Objects
setLazyEditor(Object.class, "org.jdesktop.swingx.JXTable$GenericEditor");

//with

/** c&p'ed from super */
@SuppressWarnings("unchecked")
private void setLazyValue(Hashtable h, Class c, String s) {
h.put(c, new UIDefaults.ProxyLazyValue(s));
}

/** c&p'ed from super */
private void setLazyEditor(Class c, String s) {
setLazyValue(defaultEditorsByColumnClass, c, s);
}

[/code]

It's easy enough to drop that in favour of direct creation - iff it's the reason for your problem :-)

Thanks
Jeanette

boomah
Offline
Joined: 2007-07-13

Hi. I can confirm that:

getCellEditor(0,0)

returns null in the webstart case but returns

org.jdesktop.swingx.JXTable$GenericEditor@5284b8f9

in the normal case.

Thanks, Nick.

kschaefe
Offline
Joined: 2006-06-08

Are you seeing any exceptions in the log? Sounds random, just like:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6967414

Karl

boomah
Offline
Joined: 2007-07-13

Hi.

I'm not seeing any exceptions in the webstart console.

It's a bit odd. As I said last week, I tried to get a bare bones webstart app but I couldn't quite get rid of some ClassLoader tomfoolery.

I should also say that I'm using Scala but I don't think that should cause any problems.

thanks, Nick.

kleopatra
Offline
Joined: 2003-06-11

ohh ... sounds like a bug then. Would you please file an issue in the SwingX issue tracker?

Thanks
Jeanette

kleopatra
Offline
Joined: 2003-06-11

hmm .. can't reproduce: aded a quick dummy to my CalendarExtDemo - looks okay for me:

https://jdnc-incubator.dev.java.net/demos/kleopatra/CalendarExt/Calendar...

(to see the table, click on view->show demo selector and then choose the JXTable - edit bug? in the taskpane at left)

How's that behaving in your context?

Thanks
Jeanette

boomah
Offline
Joined: 2007-07-13

hmm, this does work as expected (although I'm at home and using OSX rather than at work where I was seeing it on Ubuntu and XP).

When I'm in work tomorrow I'll try it on XP and if it works try and figure out if I'm doing anything strange when setting up my webstart app..

Thanks...