On Tue, 12 Aug 2025 11:50:19 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> If we have to call `WindowsMenuItemUI.paintMenuItem` from >> `WindowsCheckBoxMenuItemUI`, `WindowsRadioButtonMenuItemUI`, `WindowsMenuUI >> ` then `paintMenuItem `has to be static in `WindowsMenuItemUI` >> so `paintAccText ` called from `paintMenuItem` has to be static so even if >> we try to pass the parameters to `SwingUtilities3.paintAccText` from >> `WindowsMenuItemUI.paintAccText ` those parameters need to be static else we >> will be getting this kind of build error >> >> error: non-static variable disabledForeground cannot be referenced from a >> static context >> SwingUtilities3.paintAccText(g, lh, lr, disabledForeground, >> acceleratorSelectionForeground, acceleratorForeground); > > I don't see the real code that you're referring to, but I strongly believe > you can pass these colors as parameters. > > `WindowsMenuItemUI.paintMenuItem` isn't static and it has access to all the > required colors inherited from `BasicMenuItemUI`, it calls a static method > `paintMenuItem` as already passes background and foreground as parameters, > therefore you could've added more parameters if they were needed. > > One way or another, you call these static methods from a non-static method — > pass all the required parameters, maybe the `WindowsMenuItemUI` object itself > to the static methods. Unless there is a functional regression as a result (as there was for the copy/paste error), given that it is very late in the release cycle for jdk25, I strongly recommend any additional refactoring be done in a follow-up bug for JDK 26 where it can be discussed and done without the pressure of a deadline. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r2269605816