60 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
61 |
import javax.swing.MenuElement; |
import javax.swing.MenuElement; |
62 |
import javax.swing.MenuSelectionManager; |
import javax.swing.MenuSelectionManager; |
63 |
|
import javax.swing.SwingConstants; |
64 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
65 |
import javax.swing.UIDefaults; |
import javax.swing.UIDefaults; |
66 |
import javax.swing.UIManager; |
import javax.swing.UIManager; |
393 |
selectionBackground = defaults.getColor("MenuItem.selectionBackground"); |
selectionBackground = defaults.getColor("MenuItem.selectionBackground"); |
394 |
selectionForeground = defaults.getColor("MenuItem.selectionForeground"); |
selectionForeground = defaults.getColor("MenuItem.selectionForeground"); |
395 |
acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter"); |
acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter"); |
396 |
|
|
397 |
|
menuItem.setHorizontalTextPosition(SwingConstants.TRAILING); |
398 |
|
menuItem.setHorizontalAlignment(SwingConstants.LEADING); |
399 |
} |
} |
400 |
|
|
401 |
/** |
/** |
555 |
} |
} |
556 |
} |
} |
557 |
|
|
|
// paint icon |
|
|
// FIXME: should paint different icon at different button state's. |
|
|
// i.e disabled icon when button is disabled.. etc. |
|
|
Icon i = m.getIcon(); |
|
|
if (i != null) |
|
|
{ |
|
|
i.paintIcon(c, g, vr.x, vr.y); |
|
|
|
|
|
// Adjust view rectangle, s.t text would be drawn after menu item's icon. |
|
|
vr.x += i.getIconWidth() + defaultTextIconGap; |
|
|
} |
|
|
|
|
558 |
// paint text and user menu icon if it exists |
// paint text and user menu icon if it exists |
559 |
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(), |
Icon i = m.getIcon(); |
560 |
|
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, |
561 |
vertAlign, horAlign, vertTextPos, |
vertAlign, horAlign, vertTextPos, |
562 |
horTextPos, vr, ir, tr, |
horTextPos, vr, ir, tr, |
563 |
defaultTextIconGap); |
defaultTextIconGap); |
564 |
|
if (i != null) |
565 |
|
i.paintIcon(c, g, ir.x, ir.y); |
566 |
|
|
567 |
paintText(g, m, tr, m.getText()); |
paintText(g, m, tr, m.getText()); |
568 |
|
|