summaryrefslogtreecommitdiff
path: root/javax/swing
diff options
context:
space:
mode:
authorDavid Gilbert <david.gilbert@object-refinery.com>2005-09-15 20:24:13 +0000
committerDavid Gilbert <david.gilbert@object-refinery.com>2005-09-15 20:24:13 +0000
commit288276435d1b075f704a5c451acf4522fb9baf9c (patch)
tree0e6fbedb7ac8215a57440c46f2422967b428be90 /javax/swing
parentc965f5399c278d0246d1bb056bae314d17754f97 (diff)
downloadclasspath-288276435d1b075f704a5c451acf4522fb9baf9c.tar.gz
2005-09-15 David Gilbert <david.gilbert@object-refinery.com>
* 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.
Diffstat (limited to 'javax/swing')
-rw-r--r--javax/swing/SwingUtilities.java2
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java5
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java80
3 files changed, 70 insertions, 17 deletions
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index ee5fa74d4..216057e0e 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -840,7 +840,7 @@ public class SwingUtilities
iconR.width = icon.getIconWidth();
iconR.height = icon.getIconHeight();
}
- if (text == null)
+ if (text == null || text.equals(""))
{
textIconGap = 0;
textR.width = 0;
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
index fb9333934..c9aed2fb2 100644
--- a/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -268,7 +268,10 @@ public class BasicButtonUI extends ButtonUI
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),
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 8630f6102..eded1c7fa 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -84,6 +84,14 @@ public class BasicInternalFrameTitlePane extends JComponent
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 BasicInternalFrameTitlePane extends JComponent
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 BasicInternalFrameTitlePane extends JComponent
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 BasicInternalFrameTitlePane extends JComponent
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 BasicInternalFrameTitlePane extends JComponent
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 BasicInternalFrameTitlePane extends JComponent
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 @@ public class BasicInternalFrameTitlePane extends JComponent
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 @@ public class BasicInternalFrameTitlePane extends JComponent
// These buttons cannot be given focus.
return false;
}
+
}
/** The action command for the Close action. */
@@ -674,8 +721,9 @@ public class BasicInternalFrameTitlePane extends JComponent
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 @@ public class BasicInternalFrameTitlePane extends JComponent
notSelectedTitleColor = null;
closeIcon = null;
+ iconIcon = null;
+ maxIcon = null;
}
/**
@@ -698,12 +748,15 @@ public class BasicInternalFrameTitlePane extends JComponent
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 @@ public class BasicInternalFrameTitlePane extends JComponent
{
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);
}
/**