@@ -0,0 +1,2738 @@
+/*%0A * Copyright 2000-2016 JetBrains s.r.o.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.intellij.ui;%0A%0Aimport com.intellij.ui.paint.RectanglePainter;%0Aimport com.intellij.util.ui.JBEmptyBorder;%0Aimport com.intellij.util.ui.JBUI;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0A%0Aimport javax.swing.*;%0Aimport java.awt.*;%0Aimport java.awt.font.FontRenderContext;%0A%0Apublic class LabelUtil %7B%0A  @NotNull%0A  public static JLabel createLabelWithRoundCorners(@NotNull String text,%0A                                                   @Nullable Color fg,%0A                                                   @Nullable final Color bg,%0A                                                   float fontScale,%0A                                                   int roundWidth,%0A                                                   int borderVOffset,%0A                                                   int borderHOffset) %7B%0A    JBEmptyBorder emptyBorder = JBUI.Borders.empty(borderVOffset, borderHOffset);%0A    JLabel label = new JLabel(text) %7B%0A      @Override%0A      protected void paintComponent(Graphics g) %7B%0A        if (g instanceof Graphics2D) %7B%0A          Graphics2D g2d = (Graphics2D)g;%0A          g2d.setColor(bg);%0A          Rectangle textRect = getTextRect(getText(), g2d);%0A          Insets borderInsets = emptyBorder.getBorderInsets();%0A          // base line - coordinate right under text -%3E so we have to shift 1px up%0A          int baselineIncludeOffset = getBaseline(0, 0)+1;%0A          RectanglePainter.FILL.paint(g2d, 0, getHeight() - baselineIncludeOffset + textRect.y - borderInsets.top, getWidth(),%0A                                      textRect.height + borderInsets.top + borderInsets.bottom, roundWidth);%0A          super.paintComponent(g);%0A        %7D%0A      %7D%0A    %7D;%0A    Font labelFont = label.getFont();%0A    label.setFont(labelFont.deriveFont(labelFont.getSize() * fontScale));%0A    label.setForeground(fg);%0A    label.setBorder(emptyBorder);%0A    return label;%0A  %7D%0A%0A  private static Rectangle getTextRect(@NotNull String text, @NotNull Graphics2D g2d) %7B%0A    FontRenderContext frc = g2d.getFontRenderContext();%0A    return g2d.getFont().createGlyphVector(frc, text).getPixelBounds(frc, 0, 0);%0A  %7D%0A%7D%0A

implement label with rounded background area