I am maintaining some code the implements a customized Look and Feel in Java. While doing a recent upgrade of Java version (for other reasons) I found that the Look and feel broke due to a field not found on
sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;
This is in a class that is closely based on BasicMenuItemUI.layoutMenuItem()
circa Java 6u02 (here's the source). I have found that Oracle have re-factored their code to include a MenuItemLayoutHelper
in the new target version I am using, Java 6u31.
I could just use the MenuItemLayoutHelper
but that doesn't solve the problem it just puts it off until the next time the Java internals are changed around. Therefore, I have discounted this as a solution.
I am after some advise on how to achieve a left to right layout similar to BasicMenuItemUI
without needing to know the parents' maximum text offset (removing the bad dependency on sun.swing.SwingUtilities).
As albfan said, you can't. You either have to depend on the code, copy the class and use it in your program, not use it at all and use a third party library, or not use that feature.
Ok it may have been a while but I figured out I could just use my own constant instead of sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET as long as it was used consistently in the offending code. By no means an ideal solution.
On the upside bad imports from sun packages has gone into the coding rule checks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With