com.alee.laf.tabbedpane.TabbedPanePainter Maven / Gradle / Ivy
package com.alee.laf.tabbedpane;
import com.alee.api.annotations.NotNull;
import com.alee.api.annotations.Nullable;
import com.alee.painter.DefaultPainter;
import com.alee.painter.SectionPainter;
import com.alee.painter.decoration.AbstractDecorationPainter;
import com.alee.painter.decoration.IDecoration;
import javax.swing.*;
import java.awt.*;
import java.util.List;
/**
* Basic painter for {@link JTabbedPane} component.
* It is used as {@link WTabbedPaneUI} default painter.
*
* @param component type
* @param component UI type
* @param decoration type
* @author Mikle Garin
*/
public class TabbedPanePainter, D extends IDecoration>
extends AbstractDecorationPainter implements ITabbedPanePainter
{
/**
* {@link SectionPainter} that can be used to customize tab content background.
*/
@DefaultPainter ( TabContentPainter.class )
protected ITabContentPainter tabContentPainter;
@Nullable
@Override
protected List> getSectionPainters ()
{
return asList ( tabContentPainter );
}
@Override
protected void paintContent ( @NotNull final Graphics2D g2d, @NotNull final C c, @NotNull final U ui, @NotNull final Rectangle bounds )
{
paintTabContent ( g2d );
}
/**
* Paints tree background.
*
* @param g2d graphics context
*/
protected void paintTabContent ( @NotNull final Graphics2D g2d )
{
if ( tabContentPainter != null && component.getLayout () instanceof TabbedPaneLayout )
{
final TabbedPaneLayout layout = ( TabbedPaneLayout ) component.getLayout ();
tabContentPainter.prepareToPaint ( component.getSelectedIndex () );
paintSection ( tabContentPainter, g2d, layout.getContentBounds () );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy