Code
class MySynthStyleFactory extends SynthStyleFactory {
private SynthStyleFactory wrappedFactory;
public MySynthStyleFactory(SynthStyleFactory factory) {
this.wrappedFactory = factory;
}
public SynthStyle getStyle(JComponent c, Region id) {
SynthStyle s = wrappedFactory.getStyle(c, id);
//if(id==Region.INTERNAL_FRAME_TITLE_PANE||id==Region.INTERNAL_FRAME) {
if(id==Region.INTERNAL_FRAME) {
s = new TranslucentSynthSytle(s);
}
return s;
}
}
class TranslucentSynthSytle extends SynthStyle {
private final SynthStyle style;
public TranslucentSynthSytle(SynthStyle s) {
style = s;
}
public SynthPainter getPainter(final SynthContext context) {
return new SynthPainter() {
public void paintInternalFrameBackground(SynthContext context,
Graphics g, int x, int y, int w, int h) {
g.setColor(new Color(100,200,100,100));
g.fillRoundRect(x,y,w-1,h-1,15,15);
}
};
}
public boolean isOpaque(SynthContext context) {
if(context.getRegion()==Region.INTERNAL_FRAME) {
return false;
}else{
return style.isOpaque(context);
}
}
public Color getColorForState(SynthContext context, ColorType type) {
return null; //Color.RED;
}
public Font getFontForState(SynthContext context) {
return null; //new Font("MONOSPACE", Font.ITALIC, 24);
}
//...
References
is this brown square background the correct button background behaviour?
ReplyDeletehttps://picasaweb.google.com/lh/photo/jpjqW6OXUbZr-UNEWXoeNw?feat=directlink
Oops, bit ugly...
ReplyDeleteI think this will need to call JPanel#setOpaque(false):
JPanel p2 = new JPanel() {
@Override public void paintComponent(Graphics g) {
g.setColor(new Color(100,50,50,100));
g.fillRect(0,0,getWidth(), getHeight());
}
};
p2.setOpaque(false);
la Nippa,
ReplyDeleteExample.jnlp, src.zip update. Thank you for point out.
looks better!
ReplyDeleteGood job
perfect! thank you so much!
ReplyDeleteGlad to be of service :)
Delete