Skip to main content

JXLayer to wrap around JComboBox - paintLayer keep being called

2 replies [Last post]
Joined: 2004-05-04

I use JXLayer to wrap around an editable JComboBox.

I realize, when the edit cursor keep blinking in my JComboBox editable field, the overridden paintLayer method will keep being called by the system.

I was wondering whether this is a normal behavior?

Also, in some component, if I draw an animated GIF image within paintLayer, the paintLayer will also keep being called. Is this normal too?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-17

Yes, that seems perfectly normal to me.

The blinking cursor is shown because repeatedly a repaint request is issued (note: with a tiny rectangle that just is sufficient to paint that cursor).

For an animated gif the same applies.

Repaint requests will ultimately lead to invoking paint() on your component and, because JXLayer and its LayerUI are involved, to invoking painLayer().

No need to be worried I would say.


Joined: 2011-10-12

I am not sure if the topic is the same, perhaps we can reanimate this thread or start a new one:

Using JXLayer 4 there seems to be a problem with the paint() method in JTables with custom cell renderers. I designed a complex table cell renderer showing a JLabel with an icon and the String.value of the cell's value. Doing this with usual Swing commands in the method "getTableCellRendererComponent(...)" JXLayer causes a permanently repainting of the renderer. This only happens if the JTable is within a JXLayer. My solution was to do all graphics in the paint() method. That works perfectly but is a lot of work. To me it seems the problem has something to do with the font rendering in any text component (if I let the JLabel empty there is no problem).