Package client.custom

Source Code of client.custom.JCustomPane

package client.custom;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JComponent;
import javax.swing.JScrollPane;

import client.gfx.wrapper.BGTileImageEngine;
/**
* The <code>JCustomPane</code> is a subclass of <code>JScrollPane</code> which adds desired functionality to
* the <code>paintComponent()</code> method of JScrollPane. Namingly, it uses the <code>BGTileImageEngine</code>
* graphics wrapper to get the desired background of the pane. Used as a container for all the JTextAreas in the GUI.
*
* @author Priidu Neemre
*/
public class JCustomPane extends JScrollPane {
 
  private static final long serialVersionUID = 00000001L;
  private BGTileImageEngine tileEngine;
  private BufferedImage backgroundImage;
 
  public JCustomPane(JComponent component, String imagePath) {
    super(component);
    tileEngine = new BGTileImageEngine(imagePath);
  }

  public void paintComponent(Graphics g){   
    backgroundImage = tileEngine.generateTiledBackground(getWidth(), getHeight());
    g.drawImage(backgroundImage, 0, 0, null);
    super.paintComponent(g)//Text repainted after the background
  }
}
TOP

Related Classes of client.custom.JCustomPane

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.