final WebPopupMenuUI ui = ( WebPopupMenuUI ) popupMenu.getUI ();
final Painter painter = ui.getPainter ();
if ( painter instanceof WebPopupMenuPainter )
{
// Checking painter sttyle
final WebPopupMenuPainter webPainter = ( WebPopupMenuPainter ) painter;
if ( webPainter.getPopupStyle () == PopupStyle.dropdown )
{
// Checking whether this item state change affect the corner
final int zOrder = popupMenu.getComponentZOrder ( menuItem );
if ( webPainter.getCornerSide () == SwingConstants.NORTH && zOrder == 0 )
{
// Repainting only corner bounds
popupMenu.repaint ( 0, 0, popupMenu.getWidth (), menuItem.getBounds ().y );
}
else if ( webPainter.getCornerSide () == SwingConstants.SOUTH && zOrder == popupMenu.getComponentCount () - 1 )
{
// Repainting only corner bounds
final Rectangle itemBounds = menuItem.getBounds ();
final int y = itemBounds.y + itemBounds.height;
popupMenu.repaint ( 0, y, popupMenu.getWidth (), popupMenu.getHeight () - y );