TITLE:Separatorを波線で表示
#navi(../)
*Separatorを波線で表示 [#g6af9d8e]
>編集者:[[Terai Atsuhiro>terai]]~
作成日:& date;~
更新日:&lastmod;

#contents

**概要 [#jc12c5ca]
波線を使ったSeparatorを作成します。

#screenshot

**サンプルコード [#r8936d7c]
 class WavyLineSeparator extends JComponent{
   public WavyLineSeparator() {
     super();
     setPreferredSize(new Dimension(100, 3));
     setMinimumSize(new Dimension(0, 3));
     setMaximumSize(new Dimension(Integer.MAX_VALUE, 3));
     setBorder(new MatteBorder(0,0,3,0,new WavyLineIcon()));;
   }
   class WavyLineIcon implements Icon {
     public void paintIcon(Component c, Graphics g, int x, int y) {
       Graphics2D g2 = (Graphics2D)g;
       g2.setColor(SystemColor.textText);
       g2.translate(x,y);
       g2.drawLine( 0, 2, 0, 2 );
       g2.drawLine( 1, 1, 1, 1 );
       g2.drawLine( 2, 0, 3, 0 );
       g2.drawLine( 4, 1, 4, 1 );
       g2.drawLine( 5, 2, 5, 2 );
       g2.translate(-x,-y);
     }
     public int getIconWidth()  { return 6; }
       public int getIconHeight() { return 3; }
     }
   }
 }

-&jnlp;
-&jar;
-&zip;

**解説 [#q8db10c5]
波上のIconを作成して、これをMatteBorderを使って並べています。

上記のサンプルでは水平方向限定のセパレーターになります。

//**参考リンク
**コメント [#l8c965e9]
#comment