English 中文(简体)
JTable cell中可加利用的JPanel
原标题:Scrollable JPanel in JTable cell
  • 时间:2010-12-20 10:19:37
  •  标签:
  • java
  • swing

I want to create custom cell in JTable. I used custom renderer and returned JPanel object. It works but there is one problem. While program is running the JPanel draws on itself using paintComponent() method. On each "tick" (usually each 100ms) the panel is getting wider (Im drawing kind of graph) and when it becomes too big the rest is just hidden. Id like it to resize and create scrollbar. I tried several ways of putting ScrollPane but none of them worked. Basically, I want something like Thread view in Java VisualVM. Any ideas?

问题回答

很难在普通桌子囚房内安装roll,因为只有一部分单元用于表上所有囚室。 可否拆除可装饰的、仅将大量部件放在普通的JPanel,配电网布局?

如果你仍然希望使用JTable:

每一发烧都含有特别的JViewport控制。 这项“JViewport”控制实际上从事了所有滚动工作,而“JrollPane”本身只是用滚动条铺设。 由于所有囚室都使用单一电离室,你必须储存这种电离层滚动位置,并恢复每个油漆室(采用CellRenderer方法)。 But JSroll 根本需要大量布局,以便这一非常缓慢的解决办法。

May be most preferable solution: override you JPane cell renderer paint method, and this paint method must create sub-graphics (Graphics.create() ) with proper scroll offset. Scroll offset data must be stored somewhere (in table model for example). When user click on cell, JTable begin cell editing, and install cell editor. This must be special cell editor, what contains scroll pane itself. User scroll this control (none special support required) and went he finished cell editing you must save scroll position to model (in stopCellEditing() function). Then cell rendered paint itself and in paint method get content scroll offset from model. User see scrolled cell. You also can put JScrollBar inside cell rendered, so user can see scroll position (but it need special support). You can also use JViewport itself to do all pain work, but in control hard to understanding. I do not see any troubles wit use scroll pant in cell editor, so it must work. In any way it is huge work.

因此,您设立了习惯表单元,而Im假设该电码为的看法。 您可能需要在打电话到<条码>关于滚动板和电话<条码>的>和(或)<条码>;(或)<条码>在小组上(或者在滚动板上看到任何内元素)在打电话到<条码><>validate(>)以引发布局更新之前就座。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签