< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuUI.java

Print this page
rev 47462 : Fixed JDK-8178430: JMenu in GridBagLayout flickers when label text shows "..."
and is updated.
JDK-8178430: Fixed following issues with the test:
1. Throw exception in case the menu bar size is not proper.
2. Run the test for about 10 seconds, and then automatically
close the window.
3. Moved the fix from BasicMenuItemUI.java to BasicMenuUI.java
as per Sergey's suggestion.
4. Fixed the test case to correct the access to UI elements in EDT. Also, now made
sure that the main thread won't exit until the test is complete.
5.Removed unnecessary space in BasicMenuItemUI.java
6. Removed unnecessary import.
7. Moved the declaration of member variables into the constructor scope.


 209 
 210         if (changeListener != null)
 211             menuItem.removeChangeListener(changeListener);
 212 
 213         if (menuListener != null)
 214             ((JMenu)menuItem).removeMenuListener(menuListener);
 215 
 216         changeListener = null;
 217         menuListener = null;
 218         handler = null;
 219     }
 220 
 221     protected MenuDragMouseListener createMenuDragMouseListener(JComponent c) {
 222         return getHandler();
 223     }
 224 
 225     protected MenuKeyListener createMenuKeyListener(JComponent c) {
 226         return (MenuKeyListener)getHandler();
 227     }
 228 





 229     public Dimension getMaximumSize(JComponent c) {
 230         if (((JMenu)menuItem).isTopLevelMenu() == true) {
 231             Dimension d = c.getPreferredSize();
 232             return new Dimension(d.width, Short.MAX_VALUE);
 233         }
 234         return null;
 235     }
 236 
 237     /**
 238      * Sets timer to the {@code menu}.
 239      *
 240      * @param menu an instance of {@code JMenu}.
 241      */
 242     protected void setupPostTimer(JMenu menu) {
 243         Timer timer = new Timer(menu.getDelay(), new Actions(
 244                                     Actions.SELECT, menu,false));
 245         timer.setRepeats(false);
 246         timer.start();
 247     }
 248 




 209 
 210         if (changeListener != null)
 211             menuItem.removeChangeListener(changeListener);
 212 
 213         if (menuListener != null)
 214             ((JMenu)menuItem).removeMenuListener(menuListener);
 215 
 216         changeListener = null;
 217         menuListener = null;
 218         handler = null;
 219     }
 220 
 221     protected MenuDragMouseListener createMenuDragMouseListener(JComponent c) {
 222         return getHandler();
 223     }
 224 
 225     protected MenuKeyListener createMenuKeyListener(JComponent c) {
 226         return (MenuKeyListener)getHandler();
 227     }
 228 
 229     public Dimension getMinimumSize(JComponent c) {
 230         return (((JMenu)menuItem).isTopLevelMenu() == true) ?
 231             c.getPreferredSize() : null;
 232     }
 233 
 234     public Dimension getMaximumSize(JComponent c) {
 235         if (((JMenu)menuItem).isTopLevelMenu() == true) {
 236             Dimension d = c.getPreferredSize();
 237             return new Dimension(d.width, Short.MAX_VALUE);
 238         }
 239         return null;
 240     }
 241 
 242     /**
 243      * Sets timer to the {@code menu}.
 244      *
 245      * @param menu an instance of {@code JMenu}.
 246      */
 247     protected void setupPostTimer(JMenu menu) {
 248         Timer timer = new Timer(menu.getDelay(), new Actions(
 249                                     Actions.SELECT, menu,false));
 250         timer.setRepeats(false);
 251         timer.start();
 252     }
 253 


< prev index next >