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 FlatSpinnerUI with button-less JSpinner #181

Closed
ebourg opened this issue Sep 30, 2020 · 1 comment
Closed

NPE in FlatSpinnerUI with button-less JSpinner #181

ebourg opened this issue Sep 30, 2020 · 1 comment
Milestone

Comments

@ebourg
Copy link
Contributor

ebourg commented Sep 30, 2020

Hi,

I use a custom JSpinner with the buttons removed (the value is increased/decreased with the mousewheel instead). In this situation with FlatLaf 0.42 I get a NullPointerException in FlatSpinnerUI:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at com.formdev.flatlaf.ui.FlatSpinnerUI.update(FlatSpinnerUI.java:272)
	at javax.swing.JComponent.paintComponent(JComponent.java:780)
	at javax.swing.JComponent.paint(JComponent.java:1056)

Here is a minimal test case to reproduce the issue:

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        FlatDarkLaf.install();
        JFrame frame = new JFrame("FlatLaf SpinnerUI Test");
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setSize(800, 600);
        frame.setLocation(100, 100);
        frame.setVisible(true);
        frame.getContentPane().setLayout(new FlowLayout());

        JSpinner spinner = new JSpinner();
        for (Component component : spinner.getComponents()) {
            if (component.getName() != null && component.getName().endsWith("Button")) {
                spinner.remove(component);
            }
        }

        frame.getContentPane().add(spinner);
    });
}
DevCharly added a commit that referenced this issue Oct 4, 2020
… removed to create button-less spinner (issue #181)
@DevCharly
Copy link
Collaborator

Interesting use case 👍

Thx for reporting. Fixed in master branch.

@DevCharly DevCharly added this to the 0.43 milestone Oct 4, 2020
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