Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Creating a Custom Look(Skin): Synth/XML/SynthPainter

  1. #1
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Creating a Custom Look(Skin): Synth/XML/SynthPainter

    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
    Attached Images Attached Images


Similar Threads

  1. convert excel to xml and read the input from xml file
    By rahulruns in forum Object Oriented Programming
    Replies: 5
    Last Post: April 3rd, 2012, 12:13 PM
  2. Reading XML File using DOMParser and have problem with accessing xml
    By optiMystic23 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 21st, 2012, 02:22 PM
  3. custom GUI (Synth XML file) Question
    By macko in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 4th, 2011, 01:30 AM
  4. Replies: 0
    Last Post: November 16th, 2011, 08:29 AM
  5. Creating a custom panel:
    By xterradaniel in forum AWT / Java Swing
    Replies: 19
    Last Post: October 3rd, 2010, 08:15 PM