【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了TitlePanel.java提供大家参考,希望对大家有所帮助!
package com.lzw.frame;
import java.awt.*;
import java.net.URL;
import javax.swing.*;
import java.awt.Dimension;
public class TitlePanel extends JPanel {
public int width, height;
private Image img;
public TitlePanel() {
super();
URL url = getClass().getResource("/image/telFrameImage/telFramTitleImg.png");
img = new ImageIcon(url).getImage();
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
g.drawImage(img, 0, 0, width,height,this);
}
}