/[classpath]/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.8 by gnu_andrew, Sat Sep 10 15:31:51 2005 UTC revision 1.1.2.9 by gnu_andrew, Tue Sep 20 18:46:33 2005 UTC
# Line 84  public class BasicInternalFrameTitlePane Line 84  public class BasicInternalFrameTitlePane
84    public class CloseAction extends AbstractAction    public class CloseAction extends AbstractAction
85    {    {
86      /**      /**
87         * Creates a new action.
88         */
89        public CloseAction()
90        {
91          super("Close");
92        }
93        
94        /**
95       * This method is called when something closes the JInternalFrame.       * This method is called when something closes the JInternalFrame.
96       *       *
97       * @param e The ActionEvent.       * @param e The ActionEvent.
# Line 113  public class BasicInternalFrameTitlePane Line 121  public class BasicInternalFrameTitlePane
121    public class IconifyAction extends AbstractAction    public class IconifyAction extends AbstractAction
122    {    {
123      /**      /**
124         * Creates a new action.
125         */
126        public IconifyAction()
127        {
128          super("Minimize");
129        }
130    
131        /**
132       * This method is called when the user wants to iconify the       * This method is called when the user wants to iconify the
133       * JInternalFrame.       * JInternalFrame.
134       *       *
# Line 143  public class BasicInternalFrameTitlePane Line 159  public class BasicInternalFrameTitlePane
159    public class MaximizeAction extends AbstractAction    public class MaximizeAction extends AbstractAction
160    {    {
161      /**      /**
162         * Creates a new action.
163         */
164        public MaximizeAction()
165        {
166          super("Maximize");
167        }
168        /**
169       * This method is called when the user wants to maximize the       * This method is called when the user wants to maximize the
170       * JInternalFrame.       * JInternalFrame.
171       *       *
# Line 173  public class BasicInternalFrameTitlePane Line 196  public class BasicInternalFrameTitlePane
196    public class MoveAction extends AbstractAction    public class MoveAction extends AbstractAction
197    {    {
198      /**      /**
199         * Creates a new action.
200         */
201        public MoveAction()
202        {
203          super("Move");
204        }
205        /**
206       * This method is called when the user wants to drag the JInternalFrame.       * This method is called when the user wants to drag the JInternalFrame.
207       *       *
208       * @param e The ActionEvent.       * @param e The ActionEvent.
# Line 194  public class BasicInternalFrameTitlePane Line 224  public class BasicInternalFrameTitlePane
224    public class RestoreAction extends AbstractAction    public class RestoreAction extends AbstractAction
225    {    {
226      /**      /**
227         * Creates a new action.
228         */
229        public RestoreAction()
230        {
231          super("Restore");
232        }
233        /**
234       * This method is called when the user wants to restore the       * This method is called when the user wants to restore the
235       * JInternalFrame.       * JInternalFrame.
236       *       *
# Line 224  public class BasicInternalFrameTitlePane Line 261  public class BasicInternalFrameTitlePane
261    public class SizeAction extends AbstractAction    public class SizeAction extends AbstractAction
262    {    {
263      /**      /**
264         * Creates a new action.
265         */
266        public SizeAction()
267        {
268          super("Size");
269        }
270        /**
271       * This method is called when the user wants to resize the JInternalFrame.       * This method is called when the user wants to resize the JInternalFrame.
272       *       *
273       * @param e The ActionEvent.       * @param e The ActionEvent.
# Line 377  public class BasicInternalFrameTitlePane Line 421  public class BasicInternalFrameTitlePane
421    
422        int loc = width + insets.left - 1;        int loc = width + insets.left - 1;
423        int top = insets.top + 1;        int top = insets.top + 1;
       int buttonWidth = height - 2;  
424        int buttonHeight = height - 4;        int buttonHeight = height - 4;
425        if (closeButton.isVisible())        if (closeButton.isVisible())
426          {          {
427            loc -= buttonWidth + 2;            int buttonWidth = closeIcon.getIconWidth();
428            closeButton.setBounds(loc, top, buttonWidth, buttonHeight);            loc -= buttonWidth + 2;
429              closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
430          }          }
431    
432        if (maxButton.isVisible())        if (maxButton.isVisible())
433          {          {
434            loc -= buttonWidth + 2;            int buttonWidth = maxIcon.getIconWidth();
435            maxButton.setBounds(loc, top, buttonWidth, buttonHeight);            loc -= buttonWidth + 2;
436              maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
437          }          }
438    
439        if (iconButton.isVisible())        if (iconButton.isVisible())
440          {          {
441            loc -= buttonWidth + 2;            int buttonWidth = iconIcon.getIconWidth();
442            iconButton.setBounds(loc, top, buttonWidth, buttonHeight);            loc -= buttonWidth + 2;
443              iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
444          }          }
445    
446        if (title != null)        if (title != null)
# Line 466  public class BasicInternalFrameTitlePane Line 512  public class BasicInternalFrameTitlePane
512        // These buttons cannot be given focus.        // These buttons cannot be given focus.
513        return false;        return false;
514      }      }
515    
516    }    }
517    
518    /** The action command for the Close action. */    /** The action command for the Close action. */
# Line 522  public class BasicInternalFrameTitlePane Line 569  public class BasicInternalFrameTitlePane
569    /** The icon displayed in the iconify button. */    /** The icon displayed in the iconify button. */
570    protected Icon iconIcon = BasicIconFactory.createEmptyFrameIcon();    protected Icon iconIcon = BasicIconFactory.createEmptyFrameIcon();
571    
572      /** The icon displayed in the close button. */
573      protected Icon closeIcon;
574      
575    /** The JInternalFrame that this TitlePane is used in. */    /** The JInternalFrame that this TitlePane is used in. */
576    protected JInternalFrame frame;    protected JInternalFrame frame;
577    
# Line 645  public class BasicInternalFrameTitlePane Line 695  public class BasicInternalFrameTitlePane
695     */     */
696    protected void installListeners()    protected void installListeners()
697    {    {
698      propertyChangeListener = new PropertyChangeHandler();      propertyChangeListener = createPropertyChangeListener();
699      frame.addPropertyChangeListener(propertyChangeListener);      frame.addPropertyChangeListener(propertyChangeListener);
700    }    }
701    
# Line 663  public class BasicInternalFrameTitlePane Line 713  public class BasicInternalFrameTitlePane
713     */     */
714    protected void installDefaults()    protected void installDefaults()
715    {    {
     // FIXME: move icons to defaults.  
716      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
717    
718      setFont(defaults.getFont("InternalFrame.titleFont"));      title.setFont(defaults.getFont("InternalFrame.titleFont"));
719      selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground");      selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground");
720      selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground");      selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground");
721      notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground");      notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground");
722      notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground");      notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground");
723      
724        closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
725        iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
726        maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
727    }    }
728    
729    /**    /**
# Line 683  public class BasicInternalFrameTitlePane Line 736  public class BasicInternalFrameTitlePane
736      selectedTitleColor = null;      selectedTitleColor = null;
737      notSelectedTextColor = null;      notSelectedTextColor = null;
738      notSelectedTitleColor = null;      notSelectedTitleColor = null;
739        
740        closeIcon = null;
741        iconIcon = null;
742        maxIcon = null;
743    }    }
744    
745    /**    /**
# Line 691  public class BasicInternalFrameTitlePane Line 748  public class BasicInternalFrameTitlePane
748    protected void createButtons()    protected void createButtons()
749    {    {
750      closeButton = new PaneButton(closeAction);      closeButton = new PaneButton(closeAction);
751        closeButton.setText(null);
752      if (!frame.isClosable())      if (!frame.isClosable())
753        closeButton.setVisible(false);        closeButton.setVisible(false);
754      iconButton = new PaneButton(iconifyAction);      iconButton = new PaneButton(iconifyAction);
755        iconButton.setText(null);
756      if (!frame.isIconifiable())      if (!frame.isIconifiable())
757        iconButton.setVisible(false);        iconButton.setVisible(false);
758      maxButton = new PaneButton(maximizeAction);      maxButton = new PaneButton(maximizeAction);
759        maxButton.setText(null);
760      if (!frame.isMaximizable())      if (!frame.isMaximizable())
761        maxButton.setVisible(false);        maxButton.setVisible(false);
762    }    }
# Line 706  public class BasicInternalFrameTitlePane Line 766  public class BasicInternalFrameTitlePane
766     */     */
767    protected void setButtonIcons()    protected void setButtonIcons()
768    {    {
769      Icon icon = UIManager.getIcon("InternalFrame.closeIcon");      if (closeIcon != null)
770      if (icon != null)        closeButton.setIcon(closeIcon);
771        closeButton.setIcon(icon);      if (iconIcon != null)
772      icon = UIManager.getIcon("InternalFrame.iconifyIcon");        iconButton.setIcon(iconIcon);
773      if (icon != null)      if (maxIcon != null)
774        iconButton.setIcon(icon);        maxButton.setIcon(maxIcon);
     icon = UIManager.getIcon("InternalFrame.maximizeIcon");  
     if (icon != null)  
       maxButton.setIcon(icon);  
775    }    }
776    
777    /**    /**
# Line 816  public class BasicInternalFrameTitlePane Line 873  public class BasicInternalFrameTitlePane
873    public void paintComponent(Graphics g)    public void paintComponent(Graphics g)
874    {    {
875      paintTitleBackground(g);      paintTitleBackground(g);
     Font f = g.getFont();  
     FontMetrics fm = g.getFontMetrics(f);  
876      if (frame.getTitle() != null && title != null)      if (frame.getTitle() != null && title != null)
877        {        {
878          Color saved = g.getColor();          Color saved = g.getColor();
879            Font f = title.getFont();
880            g.setFont(f);
881            FontMetrics fm = g.getFontMetrics(f);
882          if (frame.isSelected())          if (frame.isSelected())
883            g.setColor(selectedTextColor);            g.setColor(selectedTextColor);
884          else          else

Legend:
Removed from v.1.1.2.8  
changed lines
  Added in v.1.1.2.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26