Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in FlatUIUtils.isCellEditor from getBorderInsets(null) #601

Closed
johnmgithub opened this issue Oct 14, 2022 · 1 comment
Closed

NPE in FlatUIUtils.isCellEditor from getBorderInsets(null) #601

johnmgithub opened this issue Oct 14, 2022 · 1 comment
Milestone

Comments

@johnmgithub
Copy link

I get a null pointer exception when using a combobox, though only after changing the LaF, strangely. The trace is:

java.lang.NullPointerException
	at com.formdev.flatlaf.ui.FlatUIUtils.isCellEditor(FlatUIUtils.java:226)
	at com.formdev.flatlaf.ui.FlatBorder.isCellEditor(FlatBorder.java:219)
	at com.formdev.flatlaf.ui.FlatBorder.getFocusWidth(FlatBorder.java:252)
	at com.formdev.flatlaf.ui.FlatBorder.getBorderInsets(FlatBorder.java:224)
	at javax.swing.border.AbstractBorder.getBorderInsets(AbstractBorder.java:75)
	at javax.swing.plaf.basic.BasicComboPopup.getPopupHeightForRowCount(BasicComboPopup.java:1241)
	at javax.swing.plaf.basic.BasicComboPopup.getPopupLocation(BasicComboPopup.java:1298)
	at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:210)
	at javax.swing.plaf.basic.BasicComboPopup.togglePopup(BasicComboPopup.java:1170)
	at javax.swing.plaf.basic.BasicComboPopup$Handler.mousePressed(BasicComboPopup.java:858)

The problem seems to be that BasicComboPopup.getPopupHeightForRowCount calls border.getBorderInsets(null) and that null component gets passed down the chain until it causes an NPE in FlatUIUtils.isCellEditor where an attempt is made to getName() for the component.

@DevCharly
Copy link
Collaborator

Thx for reporting.

Was not able to reproduce this.
In my tests the scroller border was always null in BasicComboPopup.getPopupHeightForRowCount() and border.getBorderInsets(null) is never invoked.

Anyway added the null check to FlatUIUtils.isCellEditor()

@DevCharly DevCharly added this to the 2.6 milestone Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants