Methods Summary |
---|
protected void | addSubComponents()
menuButton.setName("InternalFrameTitlePane.menuButton");
iconButton.setName("InternalFrameTitlePane.iconifyButton");
maxButton.setName("InternalFrameTitlePane.maximizeButton");
closeButton.setName("InternalFrameTitlePane.closeButton");
add(menuButton);
add(iconButton);
add(maxButton);
add(closeButton);
|
protected void | addSystemMenuItems(javax.swing.JPopupMenu menu)
// PENDING: this should all be localizable!
JMenuItem mi = (JMenuItem)menu.add(restoreAction);
mi.setMnemonic('R");
mi = (JMenuItem)menu.add(moveAction);
mi.setMnemonic('M");
mi = (JMenuItem)menu.add(sizeAction);
mi.setMnemonic('S");
mi = (JMenuItem)menu.add(iconifyAction);
mi.setMnemonic('n");
mi = (JMenuItem)menu.add(maximizeAction);
mi.setMnemonic('x");
menu.add(new JSeparator());
mi = (JMenuItem)menu.add(closeAction);
mi.setMnemonic('C");
|
protected void | assembleSystemMenu()
systemPopupMenu = new JPopupMenuUIResource();
addSystemMenuItems(systemPopupMenu);
enableActions();
menuButton = createNoFocusButton();
updateMenuIcon();
menuButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
try {
frame.setSelected(true);
} catch(PropertyVetoException pve) {
}
showSystemMenu();
}
});
JPopupMenu p = frame.getComponentPopupMenu();
if (p == null || p instanceof UIResource) {
frame.setComponentPopupMenu(systemPopupMenu);
}
if (frame.getDesktopIcon() != null) {
p = frame.getDesktopIcon().getComponentPopupMenu();
if (p == null || p instanceof UIResource) {
frame.getDesktopIcon().setComponentPopupMenu(systemPopupMenu);
}
}
setInheritsPopupMenu(true);
|
protected java.awt.LayoutManager | createLayout()
SynthContext context = getContext(this);
LayoutManager lm =
(LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
context.dispose();
return (lm != null) ? lm : new SynthTitlePaneLayout();
|
private javax.swing.JButton | createNoFocusButton()
JButton button = new JButton();
button.setFocusable(false);
button.setMargin(new Insets(0,0,0,0));
return button;
|
private int | getComponentState(javax.swing.JComponent c)
if (frame != null) {
if (frame.isSelected()) {
return SELECTED;
}
}
return SynthLookAndFeel.getComponentState(c);
|
public javax.swing.plaf.synth.SynthContext | getContext(javax.swing.JComponent c)
return getContext(c, getComponentState(c));
|
public javax.swing.plaf.synth.SynthContext | getContext(javax.swing.JComponent c, int state)
return SynthContext.getContext(SynthContext.class, c,
SynthLookAndFeel.getRegion(c), style, state);
|
private javax.swing.plaf.synth.Region | getRegion(javax.swing.JComponent c)
return SynthLookAndFeel.getRegion(c);
|
public java.lang.String | getUIClassID()
return "InternalFrameTitlePaneUI";
|
protected void | installDefaults()
super.installDefaults();
updateStyle(this);
|
protected void | installListeners()
super.installListeners();
frame.addPropertyChangeListener(this);
addPropertyChangeListener(this);
|
protected void | paint(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g)
String title = frame.getTitle();
if (title != null) {
SynthStyle style = context.getStyle();
g.setColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
g.setFont(style.getFont(context));
// Center text vertically.
FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g);
int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
fm.getDescent()) / 2;
JButton lastButton = null;
if (frame.isIconifiable()) {
lastButton = iconButton;
}
else if (frame.isMaximizable()) {
lastButton = maxButton;
}
else if (frame.isClosable()) {
lastButton = closeButton;
}
int maxX;
int minX;
boolean ltr = SynthLookAndFeel.isLeftToRight(frame);
int titleAlignment = this.titleAlignment;
if (ltr) {
if (lastButton != null) {
maxX = lastButton.getX() - titleSpacing;
}
else {
maxX = frame.getWidth() - frame.getInsets().right -
titleSpacing;
}
minX = menuButton.getX() + menuButton.getWidth() +
titleSpacing;
}
else {
if (lastButton != null) {
minX = lastButton.getX() + lastButton.getWidth() +
titleSpacing;
}
else {
minX = frame.getInsets().left + titleSpacing;
}
maxX = menuButton.getX() - titleSpacing;
if (titleAlignment == SwingConstants.LEADING) {
titleAlignment = SwingConstants.TRAILING;
}
else if (titleAlignment == SwingConstants.TRAILING) {
titleAlignment = SwingConstants.LEADING;
}
}
String clippedTitle = getTitle(title, fm, maxX - minX);
if (clippedTitle == title) {
// String fit, align as necessary.
if (titleAlignment == SwingConstants.TRAILING) {
minX = maxX - style.getGraphicsUtils(context).
computeStringWidth(context, g.getFont(), fm, title);
}
else if (titleAlignment == SwingConstants.CENTER) {
int width = style.getGraphicsUtils(context).
computeStringWidth(context, g.getFont(), fm, title);
minX = Math.max(minX, (getWidth() - width) / 2);
minX = Math.min(maxX - width, minX);
}
}
style.getGraphicsUtils(context).paintText(
context, g, clippedTitle, minX, baseline - fm.getAscent(), -1);
}
|
public void | paintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)
context.getPainter().paintInternalFrameTitlePaneBorder(context,
g, x, y, w, h);
|
public void | paintComponent(java.awt.Graphics g)
SynthContext context = getContext(this);
SynthLookAndFeel.update(context, g);
context.getPainter().paintInternalFrameTitlePaneBackground(context,
g, 0, 0, getWidth(), getHeight());
paint(context, g);
context.dispose();
|
public void | propertyChange(java.beans.PropertyChangeEvent evt)
if (evt.getSource() == this) {
if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
updateStyle(this);
}
}
else {
// Changes for the internal frame
if (evt.getPropertyName() == JInternalFrame.FRAME_ICON_PROPERTY) {
updateMenuIcon();
}
}
|
protected void | showSystemMenu()
Insets insets = frame.getInsets();
if (!frame.isIcon()) {
systemPopupMenu.show(frame, insets.left, getY() + getHeight());
} else {
systemPopupMenu.show(menuButton,
getX() - insets.left - insets.right,
getY() - systemPopupMenu.getPreferredSize().height -
insets.bottom - insets.top);
}
|
protected void | uninstallDefaults()
SynthContext context = getContext(this, ENABLED);
style.uninstallDefaults(context);
context.dispose();
style = null;
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
// Release link to systemMenu from the JInternalFrame
di.setComponentPopupMenu(null);
}
super.uninstallDefaults();
|
protected void | uninstallListeners()
frame.removePropertyChangeListener(this);
removePropertyChangeListener(this);
super.uninstallListeners();
|
private void | updateMenuIcon()Resets the menuButton icon to match that of the frame.
Icon frameIcon = frame.getFrameIcon();
SynthContext context = getContext(this);
if (frameIcon != null) {
Dimension maxSize = (Dimension)context.getStyle().get(context,
"InternalFrameTitlePane.maxFrameIconSize");
int maxWidth = 16;
int maxHeight = 16;
if (maxSize != null) {
maxWidth = maxSize.width;
maxHeight = maxSize.height;
}
if ((frameIcon.getIconWidth() > maxWidth ||
frameIcon.getIconHeight() > maxHeight) &&
(frameIcon instanceof ImageIcon)) {
frameIcon = new ImageIcon(((ImageIcon)frameIcon).
getImage().getScaledInstance(maxWidth, maxHeight,
Image.SCALE_SMOOTH));
}
}
context.dispose();
menuButton.setIcon(frameIcon);
|
private void | updateStyle(javax.swing.JComponent c)
SynthContext context = getContext(this, ENABLED);
SynthStyle oldStyle = style;
style = SynthLookAndFeel.updateStyle(context, this);
if (style != oldStyle) {
maxIcon =
style.getIcon(context,"InternalFrameTitlePane.maximizeIcon");
minIcon =
style.getIcon(context,"InternalFrameTitlePane.minimizeIcon");
iconIcon =
style.getIcon(context,"InternalFrameTitlePane.iconifyIcon");
closeIcon =
style.getIcon(context,"InternalFrameTitlePane.closeIcon");
titleSpacing = style.getInt(context,
"InternalFrameTitlePane.titleSpacing", 2);
buttonSpacing = style.getInt(context,
"InternalFrameTitlePane.buttonSpacing", 2);
String alignString = (String)style.get(context,
"InternalFrameTitlePane.titleAlignment");
titleAlignment = SwingConstants.LEADING;
if (alignString != null) {
alignString = alignString.toUpperCase();
if (alignString.equals("TRAILING")) {
titleAlignment = SwingConstants.TRAILING;
}
else if (alignString.equals("CENTER")) {
titleAlignment = SwingConstants.CENTER;
}
}
}
context.dispose();
|