SUGGESTED FIX
------- JInternalFrame.java -------
*** /tmp/dfoivH_ Thu Mar 16 16:00:20 2000
--- JInternalFrame.java Thu Mar 16 10:38:39 2000
***************
*** 767,773 ****
--- 767,776 ----
* description: Determines whether this frame can be iconified.
*/
public void setIconifiable(boolean b) {
+ Boolean oldValue = iconable ? Boolean.TRUE : Boolean.FALSE;
+ Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
iconable = b;
+ firePropertyChange("iconable", oldValue, newValue);
}
/**
------- BasicInternalFrameUI.java -------
*** /tmp/d0ROMMO Thu Mar 16 15:59:20 2000
--- BasicInternalFrameUI.java Thu Mar 16 15:51:25 2000
***************
*** 97,103 ****
int height = (getNorthPane() != null ?
getNorthPane().getMinimumSize().height : 0) +
frame.getInsets().top + frame.getInsets().bottom;
! frame.setMinimumSize(new Dimension(120, height));
}
--- 97,109 ----
int height = (getNorthPane() != null ?
getNorthPane().getMinimumSize().height : 0) +
frame.getInsets().top + frame.getInsets().bottom;
! int width = 120;
! if (getNorthPane()!=null && getNorthPane() instanceof BasicInternalFrameTitlePane) {
! width = ((BasicInternalFrameTitlePane)getNorthPane()).getMinimumWidth();
! if (width == 0) width = 120;
! else width += frame.getInsets().left + frame.getInsets().right;
! }
! frame.setMinimumSize(new Dimension(width, height));
}
***************
*** 451,456 ****
--- 457,472 ----
// glassPane.addMouseMotionListener(glassPaneDispatcher);
glassPane.setVisible(true);
}
+ } else if (JInternalFrame.TITLE_PROPERTY.equals(prop) || prop.equals("closable") || prop.equals("iconable") || prop.equals("maximizable")) {
+ Dimension dim = frame.getMinimumSize();
+ if (getNorthPane()!=null && getNorthPane() instanceof BasicInternalFrameTitlePane) {
+ dim.width = ((BasicInternalFrameTitlePane)getNorthPane()).getMinimumWidth();
+ if (dim.width == 0) dim.width = 120;
+ else dim.width += frame.getInsets().left + frame.getInsets().right;
+ }
+ frame.setMinimumSize(dim);
+ Dimension frame_dim = frame.getSize();
+ if (dim.width > frame_dim.width) frame.setSize(dim.width, frame_dim.height);
} else if ( prop.equals("ancestor") ) {
if ((frame.getParent() != null) && !componentListenerAdded ) {
f.getParent().addComponentListener(componentListener);
------- BasicInternalFrameTitlePane.java -------
*** /tmp/d__Clc_ Thu Mar 16 15:59:40 2000
--- BasicInternalFrameTitlePane.java Thu Mar 16 10:49:57 2000
***************
*** 1,5 ****
/*
! * %W% %E%
*
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*
--- 1,5 ----
/*
! * @(#)BasicInternalFrameTitlePane.java 1.32 00/02/21
*
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*
***************
*** 32,38 ****
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
! * @version %I% %G%
* @author David Kloba
* @author Steve Wilson
*/
--- 32,38 ----
* version of Swing. A future release of Swing will provide support for
* long term persistence.
*
! * @version 1.32 02/21/00
* @author David Kloba
* @author Steve Wilson
*/
***************
*** 262,280 ****
fm.getAscent() + fm.getLeading();
int titleX;
! String title = frame.getTitle();
if( BasicGraphicsUtils.isLeftToRight(frame) ) {
titleX = menuBar.getX() + menuBar.getWidth() + 2;
} else {
titleX = menuBar.getX() - 2
- SwingUtilities.computeStringWidth(fm,title);
! }
!
g.drawString(title, titleX, baseline);
g.setFont(f);
}
}
/**
* Post a WINDOW_CLOSING-like event to the frame, so that it can
* be treated like a regular Frame.
--- 262,325 ----
fm.getAscent() + fm.getLeading();
int titleX;
! Rectangle r = new Rectangle(0, 0, 0, 0);
! if (frame.isIconifiable()) r = iconButton.getBounds();
! else if (frame.isMaximizable()) r = maxButton.getBounds();
! else if (frame.isClosable()) r = closeButton.getBounds();
! int titleW;
!
! String title;
if( BasicGraphicsUtils.isLeftToRight(frame) ) {
+ if (r.x == 0) r.x = frame.getWidth()-frame.getInsets().right;
titleX = menuBar.getX() + menuBar.getWidth() + 2;
+ titleW = r.x - titleX - 3;
+ title = clippedText(frame.getTitle(), fm, titleW);
} else {
+ titleW = menuBar.getX() - r.x -r.width - 4;
+ title = clippedText(frame.getTitle(), fm, titleW);
+
titleX = menuBar.getX() - 2
- SwingUtilities.computeStringWidth(fm,title);
! }
!
g.drawString(title, titleX, baseline);
g.setFont(f);
}
}
+ protected String clippedText(String text, FontMetrics fm, int availTextWidth) {
+ if ( (text == null) || (text.equals("")) ) return "";
+ int textWidth = SwingUtilities.computeStringWidth(fm, text);
+ String clipString = "...";
+ if (textWidth > availTextWidth) {
+ int totalWidth = SwingUtilities.computeStringWidth(fm, clipString);
+ int nChars;
+ for(nChars = 0; nChars < text.length(); nChars++) {
+ totalWidth += fm.charWidth(text.charAt(nChars));
+ if (totalWidth > availTextWidth) {
+ break;
+ }
+ }
+ text = text.substring(0, nChars) + clipString;
+ }
+ return text;
+ }
+
+ public int getMinimumWidth() {
+ int w = 22;
+ if(frame.isClosable()) w += 19;
+ if(frame.isMaximizable()) w += 19;
+ if(frame.isIconifiable()) w += 19;
+ FontMetrics fm = getFontMetrics(UIManager.getFont("InternalFrame.titleFont"));
+ int title_w = fm.stringWidth(frame.getTitle());
+ if (frame.getTitle().length()>2) {
+ int subtitle_w = fm.stringWidth(frame.getTitle().substring(0, 2) + "...");
+ w += (title_w < subtitle_w) ? title_w : subtitle_w;
+ }
+ else w = title_w;
+ return w;
+ }
+
/**
* Post a WINDOW_CLOSING-like event to the frame, so that it can
* be treated like a regular Frame.
***************
*** 346,352 ****
add(maxButton);
else
remove(maxButton);
! } else if( prop.equals("iconifiable") ) {
if( (Boolean)evt.getNewValue() == Boolean.TRUE )
add(iconButton);
else
--- 391,397 ----
add(maxButton);
else
remove(maxButton);
! } else if( prop.equals("iconable") ) {
if( (Boolean)evt.getNewValue() == Boolean.TRUE )
add(iconButton);
else
------- MetalInternalFrameTitlePane.java -------
*** /tmp/dUMa4.s Thu Mar 2 20:11:14 2000
--- MetalInternalFrameTitlePane.java Thu Mar 2 19:00:55 2000
***************
*** 311,323 ****
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
int fHeight = fm.getHeight();
- titleLength = fm.stringWidth(frameTitle);
g.setColor(foreground);
int yOffset = ( (height - fm.getHeight() ) / 2 ) + fm.getAscent();
! if( !leftToRight )
! xOffset -= titleLength;
g.drawString( frameTitle, xOffset, yOffset );
xOffset += leftToRight ? titleLength + 5 : -5;
}
--- 311,338 ----
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
int fHeight = fm.getHeight();
g.setColor(foreground);
int yOffset = ( (height - fm.getHeight() ) / 2 ) + fm.getAscent();
!
! Rectangle rect = new Rectangle(0, 0, 0, 0);
! if (frame.isIconifiable()) rect = iconButton.getBounds();
! else if (frame.isMaximizable()) rect = maxButton.getBounds();
! else if (frame.isClosable()) rect = closeButton.getBounds();
! int titleW;
!
! if( leftToRight ) {
! if (rect.x == 0) rect.x = frame.getWidth()-frame.getInsets().right-2;
! titleW = rect.x - xOffset - 4;
! frameTitle = clippedText(frameTitle, fm, titleW);
! } else {
! titleW = xOffset - rect.x - rect.width - 4;
! frameTitle = clippedText(frameTitle, fm, titleW);
! xOffset -= SwingUtilities.computeStringWidth(fm, frameTitle);
! }
!
! titleLength = SwingUtilities.computeStringWidth(fm, frameTitle);
g.drawString( frameTitle, xOffset, yOffset );
xOffset += leftToRight ? titleLength + 5 : -5;
}
***************
*** 325,331 ****
int bumpXOffset;
int bumpLength;
if( leftToRight ) {
! bumpLength = width - buttonsWidth - xOffset -5;
bumpXOffset = xOffset;
} else {
bumpLength = xOffset - buttonsWidth - 5;
--- 340,346 ----
int bumpXOffset;
int bumpLength;
if( leftToRight ) {
! bumpLength = width - buttonsWidth - xOffset - 5;
bumpXOffset = xOffset;
} else {
bumpLength = xOffset - buttonsWidth - 5;
***************
*** 336,342 ****
bumps.setBumpArea( bumpLength, bumpHeight );
bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
}
!
public void setPalette(boolean b) {
isPalette = b;
--- 351,373 ----
bumps.setBumpArea( bumpLength, bumpHeight );
bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
}
!
! public int getMinimumWidth() {
! int w = 30;
! if(frame.isClosable()) w += 21;
! if(frame.isMaximizable()) w += 16 + (frame.isClosable() ? 10 : 4);
! if(frame.isIconifiable()) w += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4));
!
! FontMetrics fm = getFontMetrics(UIManager.getFont("InternalFrame.titleFont"));
! int title_w = fm.stringWidth(frame.getTitle());
! if (frame.getTitle().length()>2) {
! int subtitle_w = fm.stringWidth(frame.getTitle().substring(0, 2) + "...");
! w += (title_w < subtitle_w) ? title_w : subtitle_w;
! }
! else w = title_w;
! return w;
! }
!
public void setPalette(boolean b) {
isPalette = b;
###@###.### 2000-03-16
|