I committed this patch which fixes the clipping of the icons in the title pane of
JInternalFrame components under the MetalLookAndFeel. The main problem was that the
Action objects used "" for the 'Name' property - the buttons used this for the text,
which messed up the icon alignment. I've fixed the names in the Action objects, and
set the button text to null explicitly:
2005-09-15 David Gilbert <[EMAIL PROTECTED]>
* javax/swing/SwingUtilities.java
(layoutCompoundLabel): check for empty text string,
* javax/swing/plaf/basic/BasicButtonUI.java
(paint): check isBorderPainted() when calculating view rect,
* javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
(CloseAction): new constructor,
(IconifyAction): new constructor,
(MaximizeAction): new constructor,
(MoveAction): new constructor,
(RestoreAction): new constructor,
(SizeAction): new constructor,
(TitlePaneLayout.layoutContainer): calculate button widths from icon
widths,
(installDefaults): initialise icon fields,
(uninstallDefaults): clear icon fields,
(createButtons): set button text to null,
(setButtonIcons): use icon fields.
Regards,
Dave
Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.34
diff -u -r1.34 SwingUtilities.java
--- javax/swing/SwingUtilities.java 22 Aug 2005 11:07:02 -0000 1.34
+++ javax/swing/SwingUtilities.java 15 Sep 2005 20:22:10 -0000
@@ -840,7 +840,7 @@
iconR.width = icon.getIconWidth();
iconR.height = icon.getIconHeight();
}
- if (text == null)
+ if (text == null || text.equals(""))
{
textIconGap = 0;
textR.width = 0;
Index: javax/swing/plaf/basic/BasicButtonUI.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicButtonUI.java,v
retrieving revision 1.25
diff -u -r1.25 BasicButtonUI.java
--- javax/swing/plaf/basic/BasicButtonUI.java 15 Sep 2005 13:19:09 -0000
1.25
+++ javax/swing/plaf/basic/BasicButtonUI.java 15 Sep 2005 20:22:11 -0000
@@ -268,7 +268,10 @@
g.setFont(f);
- SwingUtilities.calculateInnerArea(b, vr);
+ if (b.isBorderPainted())
+ SwingUtilities.calculateInnerArea(b, vr);
+ else
+ vr = SwingUtilities.getLocalBounds(b);
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
b.getText(),
currentIcon(b),
Index: javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java,v
retrieving revision 1.14
diff -u -r1.14 BasicInternalFrameTitlePane.java
--- javax/swing/plaf/basic/BasicInternalFrameTitlePane.java 12 Sep 2005
23:04:55 -0000 1.14
+++ javax/swing/plaf/basic/BasicInternalFrameTitlePane.java 15 Sep 2005
20:22:12 -0000
@@ -84,6 +84,14 @@
public class CloseAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public CloseAction()
+ {
+ super("Close");
+ }
+
+ /**
* This method is called when something closes the JInternalFrame.
*
* @param e The ActionEvent.
@@ -113,6 +121,14 @@
public class IconifyAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public IconifyAction()
+ {
+ super("Minimize");
+ }
+
+ /**
* This method is called when the user wants to iconify the
* JInternalFrame.
*
@@ -143,6 +159,13 @@
public class MaximizeAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public MaximizeAction()
+ {
+ super("Maximize");
+ }
+ /**
* This method is called when the user wants to maximize the
* JInternalFrame.
*
@@ -173,6 +196,13 @@
public class MoveAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public MoveAction()
+ {
+ super("Move");
+ }
+ /**
* This method is called when the user wants to drag the JInternalFrame.
*
* @param e The ActionEvent.
@@ -194,6 +224,13 @@
public class RestoreAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public RestoreAction()
+ {
+ super("Restore");
+ }
+ /**
* This method is called when the user wants to restore the
* JInternalFrame.
*
@@ -224,6 +261,13 @@
public class SizeAction extends AbstractAction
{
/**
+ * Creates a new action.
+ */
+ public SizeAction()
+ {
+ super("Size");
+ }
+ /**
* This method is called when the user wants to resize the JInternalFrame.
*
* @param e The ActionEvent.
@@ -377,24 +421,26 @@
int loc = width + insets.left - 1;
int top = insets.top + 1;
- int buttonWidth = height - 2;
int buttonHeight = height - 4;
if (closeButton.isVisible())
{
- loc -= buttonWidth + 2;
- closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ int buttonWidth = closeIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
if (maxButton.isVisible())
{
- loc -= buttonWidth + 2;
- maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ int buttonWidth = maxIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
if (iconButton.isVisible())
{
- loc -= buttonWidth + 2;
- iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ int buttonWidth = iconIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
if (title != null)
@@ -466,6 +512,7 @@
// These buttons cannot be given focus.
return false;
}
+
}
/** The action command for the Close action. */
@@ -674,8 +721,9 @@
notSelectedTextColor =
defaults.getColor("InternalFrame.inactiveTitleForeground");
notSelectedTitleColor =
defaults.getColor("InternalFrame.inactiveTitleBackground");
- // FIXME: move other icons to here too.
closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
+ iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
+ maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
}
/**
@@ -690,6 +738,8 @@
notSelectedTitleColor = null;
closeIcon = null;
+ iconIcon = null;
+ maxIcon = null;
}
/**
@@ -698,12 +748,15 @@
protected void createButtons()
{
closeButton = new PaneButton(closeAction);
+ closeButton.setText(null);
if (!frame.isClosable())
closeButton.setVisible(false);
iconButton = new PaneButton(iconifyAction);
+ iconButton.setText(null);
if (!frame.isIconifiable())
iconButton.setVisible(false);
maxButton = new PaneButton(maximizeAction);
+ maxButton.setText(null);
if (!frame.isMaximizable())
maxButton.setVisible(false);
}
@@ -715,13 +768,10 @@
{
if (closeIcon != null)
closeButton.setIcon(closeIcon);
- // FIXME: fetch these icons in the installDefaults() method
- Icon icon = UIManager.getIcon("InternalFrame.iconifyIcon");
- if (icon != null)
- iconButton.setIcon(icon);
- icon = UIManager.getIcon("InternalFrame.maximizeIcon");
- if (icon != null)
- maxButton.setIcon(icon);
+ if (iconIcon != null)
+ iconButton.setIcon(iconIcon);
+ if (maxIcon != null)
+ maxButton.setIcon(maxIcon);
}
/**
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches