|
|
|
@ -21,6 +21,8 @@ import com.fr.stable.StringUtils;
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.swing.border.Border; |
|
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
|
import javax.swing.plaf.PanelUI; |
|
|
|
|
import javax.swing.plaf.basic.BasicPanelUI; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.geom.Rectangle2D; |
|
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
@ -42,6 +44,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { |
|
|
|
|
super(widget, initSize); |
|
|
|
|
|
|
|
|
|
setUI(new NoBackgroundPaneUI()); |
|
|
|
|
setOpaque(false); |
|
|
|
|
setBackupBound(null); |
|
|
|
|
|
|
|
|
@ -51,6 +54,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setUI(PanelUI ui) { |
|
|
|
|
if (ui instanceof NoBackgroundPaneUI) { |
|
|
|
|
super.setUI(ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Background getBackground4Painting() { |
|
|
|
|
return this.background4Painting; |
|
|
|
|
} |
|
|
|
@ -288,6 +298,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
|
|
|
|
|
// 设计器预览界面中绘制组件背景效果
|
|
|
|
|
public void paintBackground(Graphics2D g2d) { |
|
|
|
|
if (isOpaque()) { |
|
|
|
|
g2d.setColor(getBackground()); |
|
|
|
|
g2d.fillRect(0, 0, getWidth(), getHeight()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Background background4Painting = getBackground4Painting(); |
|
|
|
|
if (background4Painting != null) { |
|
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
@ -311,12 +326,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void paintForeground(Graphics2D g2d) { |
|
|
|
|
super.paint(g2d); |
|
|
|
|
super.paintComponent(g2d); |
|
|
|
|
super.paintBorder(g2d); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paint(Graphics g) { |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
this.clipByRoundedBorder((Graphics2D) g); |
|
|
|
|
this.paintBackground((Graphics2D) g); |
|
|
|
|
this.paintBorderImage((Graphics2D) g); |
|
|
|
@ -378,4 +393,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class NoBackgroundPaneUI extends BasicPanelUI { |
|
|
|
|
@Override |
|
|
|
|
public void update(Graphics g, JComponent c) { |
|
|
|
|
paint(g, c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |