You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a custom CellRenderer. That right now is nothing except public class Picture_Renderer<T> extends DefaultCellRenderer {}
That in DefaulCellRenderer calls public DefaultCellRenderer() { //this(new ElementId(Button.ELEMENT_ID), Styles.ROOT_STYLE, null); // I believe the above is a mistake as we should be using the default // style if none is specified. It is a change in behavior, though. // 2020-11-27 this(new ElementId(Button.ELEMENT_ID), null, null); }
setting the Element_ID to "button"
In Listbox , during making of the Element it calls
if( cellRenderer == null ) { // Create a default one cellRenderer = new DefaultCellRenderer<>(baseElementId.child("item"), style); } else { **cellRenderer.configureStyle(baseElementId.child("item"), style);** }
where it should set the elementID to list.item (what it is doing with the default one)
But unfort. in defaultCellRenderer it never overwrites the elementID as it is not null
Due to the "wrong" elementID there can be issues with the styling
--> See the cells have an own "visible" background while usually they dont
So - I will get around that but maybe it should be considered to either change the elementID in the constructor (why is it Button ?) or change the behaviour of public void configureStyle( ElementId elementId, String style ) to always let it set the style (do you mean
if(!( this.elementId == null )) insteadt of if( this.elementId == null ) ?
The text was updated successfully, but these errors were encountered:
configureStyle() should only change the style if the user hasn't already specified one. If the user specifies their own style then it is assumed to be better than one that the list box would force.
Most subclasses should use a real super constructor and not rely on the default. But for code that did rely on the default constructor, I could not lightly change the behavior for any code that was relying on it. Prior to list box enforcing its own child styles (like list item) listbox items were buttons by default. (In fact, that's what DefaultCellRenderer is creating in get view.)
When creating your own DefaultCellRenderer subclass, either specify the element ID you want or call the super constructor with null: super(null, null)
...then you will inherit the list's styling for items.
Note: it is also fine to ask these sorts of questions on the jMonkeyEngine forum if you like. Sometimes these messages get lost in the github spam and I don't see them until late. (I was lucky this time. :) )
Hi PSpeed,
I am trying to write a custom CellRenderer. That right now is nothing except
public class Picture_Renderer<T> extends DefaultCellRenderer {}
That in DefaulCellRenderer calls
public DefaultCellRenderer() { //this(new ElementId(Button.ELEMENT_ID), Styles.ROOT_STYLE, null); // I believe the above is a mistake as we should be using the default // style if none is specified. It is a change in behavior, though. // 2020-11-27 this(new ElementId(Button.ELEMENT_ID), null, null); }
setting the Element_ID to "button"
In Listbox , during making of the Element it calls
if( cellRenderer == null ) { // Create a default one cellRenderer = new DefaultCellRenderer<>(baseElementId.child("item"), style); } else { **cellRenderer.configureStyle(baseElementId.child("item"), style);** }
where it should set the elementID to list.item (what it is doing with the default one)
But unfort. in defaultCellRenderer it never overwrites the elementID as it is not null
@Override public void configureStyle( ElementId elementId, String style ) { if( this.elementId == null ) { this.elementId = elementId; } if( this.style == null ) { this.style = style; } }
Due to the "wrong" elementID there can be issues with the styling
--> See the cells have an own "visible" background while usually they dont
So - I will get around that but maybe it should be considered to either change the elementID in the constructor (why is it Button ?) or change the behaviour of public void configureStyle( ElementId elementId, String style ) to always let it set the style (do you mean
if(!( this.elementId == null )) insteadt of if( this.elementId == null ) ?
The text was updated successfully, but these errors were encountered: