jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java
author yan
Mon, 30 Jun 2014 16:32:36 +0400
changeset 25178 dbab904451e9
parent 23715 54ae9dd9df73
permissions -rw-r--r--
8046434: Fix doclint warnings from javax.swing.plaf.metal package Reviewed-by: alexsch Contributed-by: Andrei Eremeev <andrei.eremeev@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
     2
 * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4199
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.metal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Metal implementation of JInternalFrame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class MetalInternalFrameUI extends BasicInternalFrameUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  private static final PropertyChangeListener metalPropertyChangeListener =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        new MetalPropertyChangeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    50
  /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    51
   * The property {@code JInternalFrame.isPalette}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    52
   */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  protected static String IS_PALETTE   = "JInternalFrame.isPalette";
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents: 2
diff changeset
    54
  private static String IS_PALETTE_KEY = "JInternalFrame.isPalette";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  private static String FRAME_TYPE     = "JInternalFrame.frameType";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  private static String NORMAL_FRAME   = "normal";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  private static String PALETTE_FRAME  = "palette";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  private static String OPTION_DIALOG  = "optionDialog";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    60
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    61
  /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    62
   * Constructs a new {@code MetalInternalFrameUI} instance.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    63
   *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    64
   * @param b an internal frame
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    65
   */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  public MetalInternalFrameUI(JInternalFrame b)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    super(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    70
  /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    71
   * Constructs a new {@code MetalInternalFrameUI} instance.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    72
   *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    73
   * @param c a component
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    74
   * @return a new {@code MetalInternalFrameUI} instance
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
    75
   */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  public static ComponentUI createUI(JComponent c)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      return new MetalInternalFrameUI( (JInternalFrame) c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  public void installUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    super.installUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents: 2
diff changeset
    83
    Object paletteProp = c.getClientProperty(IS_PALETTE_KEY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    if ( paletteProp != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        setPalette( ((Boolean)paletteProp).booleanValue() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    Container content = frame.getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    stripContentBorder(content);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    //c.setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      frame = (JInternalFrame)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      Container cont = ((JInternalFrame)(c)).getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      if (cont instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        JComponent content = (JComponent)cont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if ( content.getBorder() == handyEmptyBorder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
          content.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      super.uninstallUI(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        super.installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        frame.addPropertyChangeListener(metalPropertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        frame.removePropertyChangeListener(metalPropertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        super.uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  protected void installKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      super.installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      ActionMap map = SwingUtilities.getUIActionMap(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      if (map != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
          // BasicInternalFrameUI creates an action with the same name, we override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
          // it as Metal frames do not have system menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
          map.remove("showSystemMenu");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  protected void uninstallKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
      super.uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    protected void uninstallComponents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        titlePane = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        super.uninstallComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  private void stripContentBorder(Object c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if ( c instanceof JComponent ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            JComponent contentComp = (JComponent)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            Border contentBorder = contentComp.getBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            if (contentBorder == null || contentBorder instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                contentComp.setBorder( handyEmptyBorder );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  protected JComponent createNorthPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      return new MetalInternalFrameTitlePane(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  private void setFrameType( String frameType )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      if ( frameType.equals( OPTION_DIALOG ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
          LookAndFeel.installBorder(frame, "InternalFrame.optionDialogBorder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
          ((MetalInternalFrameTitlePane)titlePane).setPalette( false );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      else if ( frameType.equals( PALETTE_FRAME ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
          LookAndFeel.installBorder(frame, "InternalFrame.paletteBorder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
          ((MetalInternalFrameTitlePane)titlePane).setPalette( true );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
          LookAndFeel.installBorder(frame, "InternalFrame.border");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
          ((MetalInternalFrameTitlePane)titlePane).setPalette( false );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
   170
  /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
   171
   * If {@code isPalette} is {@code true}, sets palette border and title
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
   172
   *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
   173
   * @param isPalette if {@code true}, sets palette border and title
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23715
diff changeset
   174
   */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  // this should be deprecated - jcs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  public void setPalette(boolean isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    if (isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        LookAndFeel.installBorder(frame, "InternalFrame.paletteBorder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        LookAndFeel.installBorder(frame, "InternalFrame.border");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    ((MetalInternalFrameTitlePane)titlePane).setPalette(isPalette);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  private static class MetalPropertyChangeHandler implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        PropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      public void propertyChange(PropertyChangeEvent e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
          String name = e.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
          JInternalFrame jif = (JInternalFrame)e.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
          if (!(jif.getUI() instanceof MetalInternalFrameUI)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
          MetalInternalFrameUI ui = (MetalInternalFrameUI)jif.getUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
          if ( name.equals( FRAME_TYPE ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
          {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
              if ( e.getNewValue() instanceof String )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                  ui.setFrameType( (String) e.getNewValue() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          }
4199
151e13fd2df1 6657026: Numerous static security flaws in Swing (findbugs)
malenkov
parents: 2
diff changeset
   207
          else if ( name.equals(IS_PALETTE_KEY) )
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
          {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
              if ( e.getNewValue() != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                  ui.setPalette( ((Boolean)e.getNewValue()).booleanValue() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
              else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                  ui.setPalette( false );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
          } else if ( name.equals( JInternalFrame.CONTENT_PANE_PROPERTY ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
              ui.stripContentBorder(e.getNewValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  } // end class MetalPropertyChangeHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private class BorderListener1 extends BorderListener implements SwingConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        Rectangle getIconBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            boolean leftToRight = MetalUtils.isLeftToRight(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            int xOffset = leftToRight ? 5 : titlePane.getWidth() - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            Rectangle rect = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            if ( icon != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    xOffset -= icon.getIconWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                int iconY = ((titlePane.getHeight() / 2) - (icon.getIconHeight() /2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                rect = new Rectangle(xOffset, iconY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    icon.getIconWidth(), icon.getIconHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            return rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        public void mouseClicked(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            if (e.getClickCount() == 2 && e.getSource() == getNorthPane() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                frame.isClosable() && !frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                Rectangle rect = getIconBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                if ((rect != null) && rect.contains(e.getX(), e.getY())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                    frame.doDefaultCloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    super.mouseClicked(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                super.mouseClicked(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    };    /// End BorderListener Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Returns the <code>MouseInputAdapter</code> that will be installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * on the TitlePane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param w the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @return the <code>MouseInputAdapter</code> that will be installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * on the TitlePane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    protected MouseInputAdapter createBorderListener(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return new BorderListener1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
}