Update GradientPanel's opaque properly.
This commit is contained in:
parent
46d301df94
commit
8cd9755616
@ -441,7 +441,7 @@ public abstract class Components {
|
|||||||
|
|
||||||
public GradientPanel(@Nullable final LayoutManager layout, @Nullable final Color gradientColor) {
|
public GradientPanel(@Nullable final LayoutManager layout, @Nullable final Color gradientColor) {
|
||||||
super( layout );
|
super( layout );
|
||||||
this.gradientColor = gradientColor;
|
setGradientColor( gradientColor );
|
||||||
setBackground( null );
|
setBackground( null );
|
||||||
setAlignmentX( LEFT_ALIGNMENT );
|
setAlignmentX( LEFT_ALIGNMENT );
|
||||||
}
|
}
|
||||||
@ -453,17 +453,32 @@ public abstract class Components {
|
|||||||
|
|
||||||
public void setGradientColor(@Nullable final Color gradientColor) {
|
public void setGradientColor(@Nullable final Color gradientColor) {
|
||||||
this.gradientColor = gradientColor;
|
this.gradientColor = gradientColor;
|
||||||
revalidate();
|
updatePaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doLayout() {
|
public void setBackground(@Nullable final Color bg) {
|
||||||
super.doLayout();
|
super.setBackground( bg );
|
||||||
|
updatePaint();
|
||||||
if (gradientColor != null) {
|
|
||||||
paint = new GradientPaint( new Point( 0, 0 ), gradientColor, new Point( getWidth(), getHeight() ), gradientColor.darker() );
|
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBounds(final int x, final int y, final int width, final int height) {
|
||||||
|
super.setBounds( x, y, width, height );
|
||||||
|
updatePaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePaint() {
|
||||||
|
setOpaque( (getGradientColor() != null) || (getBackground() != null) );
|
||||||
|
|
||||||
|
if (gradientColor == null) {
|
||||||
|
paint = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
paint = new GradientPaint( new Point( 0, 0 ), gradientColor,
|
||||||
|
new Point( getWidth(), getHeight() ), gradientColor.darker() );
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user