开发者

Java Swing JTable cell in "edit" mode uses different set of settings?

开发者 https://www.devze.com 2022-12-18 08:49 出处:网络
I have set some parameters for my JTable, but it seems they are in effect only in what I call \"view\" mode. When editing cell content, nothing works.

I have set some parameters for my JTable, but it seems they are in effect only in what I call "view" mode. When editing cell content, nothing works.

In the screenshot below you can see how the font size reverted back to default. (Large one is what I set and what I want to see).

Also, I have default Locale set to Germany so that my decimal numb开发者_如何学编程ers would use commas as in 12,24 (instead of US 12.24 style) - which also stops working as soon as I try editing cell. It reverts back to US dot style, and after I hit Enter it gets displayed with comma again. E.g. if I enter 12,24 cell does not accept it as invalid double. But when I enter 12.24, after I hit Enter, it is displayed as 12,24 - proper German style :)

So in short it looks like cell-in-editing-mode uses a different set of settings... how can I change those or, preferably, make it use the same as in non-editing mode?

cell behavior http://img96.imageshack.us/img96/9118/jtablebehavior.png


You can set the locale on the component itself, as shown here. For better control you can define your own cell editor, as discussed in this tutorial. In addition to the examples there, here is a complete editor/renderer example.

0

精彩评论

暂无评论...
验证码 换一张
取 消