static {
   TUIManager.registerIcon(
       TopoSensorModel.class,
       "/org/infosec/ismp/applet/manager/model/image/TopoSensorModel-H.gif");
   TUIManager.registerImage(
       TopoSensorModel.class,
       "/org/infosec/ismp/applet/manager/model/image/TopoSensorModel-DH.gif");
   TWaverUtil.registerImageIcon("TopoSensorModel", DC);
   TWaverUtil.registerImageIcon("TopoSensorModelSmall", C);
 }
public class FreeToolBar extends JPanel {

  private String backgroundImageURL = FreeUtil.getImageURL("toolbar_background.png");
  private int preferredHeight = TWaverUtil.getImageIcon(backgroundImageURL).getIconHeight();
  private TexturePaint paint = FreeUtil.createTexturePaint(backgroundImageURL);
  private int buttonGap = 2;

  public FreeToolBar() {
    init();
  }

  private void init() {
    this.setLayout(new FlowLayout(FlowLayout.LEADING, buttonGap, 0));
    this.setBorder(BorderFactory.createEmptyBorder(2, 5, 0, 5));
  }

  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;
    g2d.setPaint(paint);
    g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
  }

  @Override
  public Dimension getPreferredSize() {
    return new Dimension(super.getPreferredSize().width, preferredHeight);
  }
}
public class FreePasswordField extends JPasswordField {

  private String backgroundImageURL = FreeUtil.getImageURL("textfield_background.png");
  private Image backgroundLeftImage = FreeUtil.getImage("textfield_background_left.png");
  private Image backgroundRightImage = FreeUtil.getImage("textfield_background_right.png");
  private ImageIcon backgroundImageIcon = TWaverUtil.getImageIcon(backgroundImageURL);
  private TexturePaint paint = FreeUtil.createTexturePaint(backgroundImageURL);
  private Border border = BorderFactory.createEmptyBorder(1, 3, 1, 3);
  private Font font = FreeUtil.FONT_12_PLAIN;

  public FreePasswordField() {
    init();
  }

  private void init() {
    this.setBorder(border);
    this.setUI(
        new MetalTextFieldUI() {

          @Override
          protected void paintBackground(Graphics g) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.setPaint(paint);
            g2d.fillRect(0, 0, getWidth(), getHeight());

            // paint left side image.
            g2d.drawImage(backgroundLeftImage, 0, 0, null);

            // paint right side image.
            g2d.drawImage(
                backgroundRightImage, getWidth() - backgroundRightImage.getWidth(null), 0, null);
          }
        });

    this.setFont(font);
  }

  @Override
  public Dimension getPreferredSize() {
    return new Dimension(super.getPreferredSize().width, backgroundImageIcon.getIconHeight());
  }

  public void setEchoChar(char c) {
    super.setEchoChar(c);
  }
}