分だけのカッコ良いアプリを作りたい,の巻
サンプル・ソース群

 

「Musi_chanButtonUI.java」のソースコード
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;

/**
 * Original look&feel (button).
 * 
 * @author Musi_chan
 * (Musi_chan@cool.biglobe.ne.jp)
 * @version 2002/05/09 11:22
 */
public class Musi_chanButtonUI extends MetalButtonUI {
  public static ComponentUI createUI(JComponent c) {
    return new Musi_chanButtonUI();
  }

  public void paint(Graphics g,JComponent c) {
    super.paint(g,c);

    Graphics2D g2d;
    GradientPaint gradient;
    Rectangle rect;

    g2d=(Graphics2D)g;
    gradient=new GradientPaint(0.0f,(float)c.getHeight()/2
      ,Musi_chanTheme.getCompGradColor1(),0.0f,0.0f
      ,Musi_chanTheme.getCompGradColor2());
    rect=new Rectangle(0,0,c.getWidth(),c.getHeight()/2);
    g2d.setPaint(gradient);
    g2d.fill(rect);
    gradient=new GradientPaint(0.0f,(float)c.getHeight()/2
      ,Musi_chanTheme.getCompGradColor3(),0.0f,(float)c.getHeight()
      ,Musi_chanTheme.getCompGradColor4());
    rect=new Rectangle(0,c.getHeight()/2,c.getWidth(),c.getHeight());
    g2d.setPaint(gradient);
    g2d.fill(rect);
  }
}


「Musi_chanTextFieldUI.java」のソースコード
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

/**
 * Original look&feel (textfield).
 * 
 * @author Musi_chan
 * (Musi_chan@cool.biglobe.ne.jp)
 * @version 2002/05/09 11:26
 */
public class Musi_chanTextFieldUI extends BasicTextFieldUI{
  protected JComponent myComponent;

  Musi_chanTextFieldUI(JComponent c) {
    super();
    myComponent=c;
  }

  public static ComponentUI createUI(JComponent c) {
    return new Musi_chanTextFieldUI(c);
  }

  protected void paintBackground(Graphics g) {
    super.paintBackground(g);

    Graphics2D g2d;
    GradientPaint gradient;
    Rectangle rect;
    Rectangle editRect;

    g2d=(Graphics2D)g;
    editRect=getVisibleEditorRect();
    gradient=new GradientPaint(0.0f,(float)editRect.height/2
      ,Musi_chanTheme.getCompGradColor1(),0.0f,0.0f
      ,Musi_chanTheme.getCompGradColor2());
    rect=new Rectangle(editRect.x,editRect.y
      ,editRect.x+editRect.width,editRect.y+editRect.height/2);
    g2d.setPaint(gradient);
    g2d.fill(rect);
    gradient=new GradientPaint(0.0f,(float)editRect.height/2
      ,Musi_chanTheme.getCompGradColor3(),0.0f,(float)editRect.height
      ,Musi_chanTheme.getCompGradColor4());
    rect=new Rectangle(editRect.x,editRect.y+editRect.height/2
      ,editRect.x+editRect.width,editRect.y+editRect.height);
    g2d.setPaint(gradient);
    g2d.fill(rect);
  }
}

戻る