statusbar progress text slipping

This commit is contained in:
Alexey Pegov
2010-06-24 18:02:53 +04:00
parent 1cffb4ba2a
commit 77cb56f591
2 changed files with 19 additions and 2 deletions
@@ -86,6 +86,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
textAndProgress.add(myText, BorderLayout.CENTER);
final NonOpaquePanel progressWrapper = new NonOpaquePanel(new GridBagLayout());
progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
final GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.weighty = 1;
@@ -58,7 +58,7 @@ public class TextPanel extends JComponent {
@Override
protected void paintComponent(final Graphics g) {
final String s = getText();
String s = getText();
if (s != null) {
final Rectangle bounds = getBounds();
final Insets insets = getInsets();
@@ -68,12 +68,28 @@ public class TextPanel extends JComponent {
UIUtil.applyRenderingHints(g2);
final FontMetrics fm = g2.getFontMetrics();
final int sWidth = fm.stringWidth(s);
int x = insets.left;
if (myAlignment == JComponent.CENTER_ALIGNMENT || myAlignment == JComponent.RIGHT_ALIGNMENT) {
final int sWidth = g2.getFontMetrics().stringWidth(s);
x = myAlignment == JComponent.CENTER_ALIGNMENT ? (bounds.width - sWidth) / 2 : bounds.width - insets.right - sWidth;
}
final Rectangle textR = new Rectangle();
final Rectangle iconR = new Rectangle();
final Rectangle viewR = new Rectangle(bounds);
textR.x = textR.y = textR.width = textR.height = 0;
viewR.width -= insets.left;
viewR.width -= insets.right;
if (sWidth > (bounds.width - insets.left - insets.right)) {
s = SwingUtilities
.layoutCompoundLabel(fm, s, null, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.TRAILING,
bounds, iconR, textR, 0);
}
final int y = UIUtil.getStringY(s, bounds, g2);
if (SystemInfo.isMac && myDecorate) {
g2.setColor(new Color(215, 215, 215));