Index: src/org/netbeans/core/Splash.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/Splash.java,v retrieving revision 1.55 diff -u -r1.55 Splash.java --- src/org/netbeans/core/Splash.java 28 Feb 2002 13:08:41 -0000 1.55 +++ src/org/netbeans/core/Splash.java 1 Mar 2002 14:21:43 -0000 @@ -227,16 +227,25 @@ "org.netbeans.core.Bundle", // NOI18N Locale.getDefault(), Splash.class.getClassLoader()); - StringTokenizer st = new StringTokenizer( - bundle.getString("SplashRunningTextBounds"), " ,"); // NOI18N - view = new Rectangle(Integer.parseInt(st.nextToken()), - Integer.parseInt(st.nextToken()), - Integer.parseInt(st.nextToken()), - Integer.parseInt(st.nextToken())); - Integer rgb = Integer.decode( - bundle.getString("SplashRunningTextColor")); - color_text = new Color(rgb.intValue()); - Font font = new Font("Dialog", Font.PLAIN, 12); + StringTokenizer st = new StringTokenizer( + bundle.getString("SplashRunningTextBounds"), " ,"); // NOI18N + view = new Rectangle(Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken())); + Integer rgb = Integer.decode( + bundle.getString("SplashRunningTextColor")); + color_text = new Color(rgb.intValue()); + int size = 12; + try { + String sizeStr = bundle.getString("SplashRunningTextFontSize"); + size = Integer.parseInt(sizeStr); + } catch(MissingResourceException e){ + //ignore - use default size + } + + Font font = new Font("Dialog", Font.PLAIN, size); + setFont(font); // NOI18N fm = getFontMetrics(font); } @@ -245,7 +254,6 @@ * Defines the single line of text this component will display. */ public void setText(String text) { - this.text = text; if (text == null) { repaint(dirty); return; @@ -253,6 +261,8 @@ if (fm == null) return; + + adjustText(text); SwingUtilities.layoutCompoundLabel(fm, text, null, BOTTOM, LEFT, BOTTOM, LEFT, @@ -262,7 +272,42 @@ repaint(dirty); this.dirty = new Rectangle(rect); } + + /** + * Creates new text with the ellipsis at the end when text width is + * bigger than allowed space + */ + private void adjustText(String text){ + String newText = null; + String newString; + + if (text == null) + return ; + if (fm == null) + return; + + int width = fm.stringWidth(text); + + if (width > view.width) { + StringTokenizer st = new StringTokenizer(text); + while (st.hasMoreTokens()) { + String element = st.nextToken(); + if (newText == null) + newString = element; + else + newString = newText + " " + element; // NOI18N + if (fm.stringWidth(newString + "...") > view.width) { // NOI18N + this.text = newText + "..."; // NOI18N + break; + } else + newText = newString; + + } + } else + this.text = text; + } + /** * Override update to *not* erase the background before painting. */