2个回答
展开全部
没有这样的方法
但是可以自己做一个这样的JavaBean
这是我做的一个继承JPanel可以实现设置背景的JavaBean
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.LayoutManager;
import javax.swing.JPanel;
public class PanelBean extends JPanel {
private static final long serialVersionUID = 1L;
private Image image;
public PanelBean(LayoutManager layout, boolean isDoubleBuffered) {
super(layout, isDoubleBuffered);
}
public PanelBean(LayoutManager layout) {
this(layout, true);
}
public PanelBean(boolean isDoubleBuffered) {
this(new FlowLayout(), isDoubleBuffered);
}
public PanelBean() {
this(true);
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
public void paintImage(Image image) {
Graphics g = this.getGraphics();
Insets insets = this.getInsets();
if (insets == null)
g.drawImage(image, 0, 0, this);
else
g.drawImage(image, insets.left, insets.top, this);
}
public void paintImage() {
this.paintImage(this.image);
}
}
但是可以自己做一个这样的JavaBean
这是我做的一个继承JPanel可以实现设置背景的JavaBean
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.LayoutManager;
import javax.swing.JPanel;
public class PanelBean extends JPanel {
private static final long serialVersionUID = 1L;
private Image image;
public PanelBean(LayoutManager layout, boolean isDoubleBuffered) {
super(layout, isDoubleBuffered);
}
public PanelBean(LayoutManager layout) {
this(layout, true);
}
public PanelBean(boolean isDoubleBuffered) {
this(new FlowLayout(), isDoubleBuffered);
}
public PanelBean() {
this(true);
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
public void paintImage(Image image) {
Graphics g = this.getGraphics();
Insets insets = this.getInsets();
if (insets == null)
g.drawImage(image, 0, 0, this);
else
g.drawImage(image, insets.left, insets.top, this);
}
public void paintImage() {
this.paintImage(this.image);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询