I just started customizing skins with Synth L&F, I started with customizing JScrollBar's looks, I manage to get what i want by hard-coding the scrollBar painter of SynthPainter. Then I becamse curious with Nimbus' ScrollBar(which is very cool) and i found out its made out of an image, not a hard-coded rectangle/geometric bar, even some free Synthetica L&Fs where i Opened the codes, finding that scrollBar's were made of images. Now I tried to create my own, following strictly the Nimbus and Other L&F's scrollbar's image Dimensions, I did some painting of images but I ended up making it ragged(ragged edges), it looks very awful. Ill show the very basic codes i made making a scrollbar out of an image
My SynthPainter
import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import javax.swing.ImageIcon; import javax.swing.plaf.synth.SynthContext; import javax.swing.plaf.synth.SynthPainter; public class TargetSynth1Painter extends SynthPainter { @Override public void paintScrollBarThumbBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ImageIcon thumb = (ImageIcon) context.getStyle().getIcon(context, "TargetSynth.scrollBarThumb.background"); g2d.drawImage(thumb.getImage(), x, y, w, h, null); } }
My Synth XML(Im sorry for the code tag, i dont know if theres an XML tag that i can use)
<synth> <style id="scrollBarThumb"> <object id="TargetSynth1Painter" class="targetsynth1.TargetSynth1Painter"></object> <state> <imageIcon id="scrollBarThumbBackground" path="http://www.javaprogrammingforums.com/images/scroll_bar_thumb.png"/> <property key="TargetSynth.scrollBarThumb.background" type="idref" value="scrollBarThumbBackground"/> <painter method="scrollBarThumbBackground" idref="TargetSynth1Painter" /> </state> </style> <bind style="scrollBarThumb" type="region" key="ScrollBarThumb"/> </synth>
I made an attachment, so the object can be seen without running anycode.
I know im missing alot of things here especially with Graphics painting, i just cant figure out where i need to start, to make a good scrollbar out of an image just like Nimbus and others out there. From a small dimension image, it will retain its quality even if it is stretched, I hope you understand what i want here. thanks in advance