已经在Layer Pane层设置背景图片了,然后在ContentPane层 放置组件JTextArea
输出的时候会出现背景图片隐藏起来和 出现显示混乱的问题
更新//
已经找到解决办法了,下面贴一下可以怎么解决这个问题,希望可以帮助到遇到同样问题的小伙伴。
// jp_top 属于JPanel类型
jp_top = new JPanel() {
ImageIcon imageIcon = new ImageIcon("timg.jpg");
// 这里的timg.jpg 是你想要放在面板里的照片,我将照片放在对应的项目文件夹下
{
this.setOpaque(false);
this.setLayout(new BorderLayout());
}
public void paintComponent(Graphics g) {
g.drawImage(imageIcon.getImage(), 0, 0, getSize().width, getSize().height, this);
super.paintComponents(g);
}
}; //这就可以解决了我之前在面板上添加组件出现的问题了
import javax.swing.*;
import java.awt.*;
public class Content_Layer_RootPane extends JFrame {
NewLabel nl=new NewLabel();
public Content_Layer_RootPane() {
super("你好!明天");
init();
}
public void init() {
setSize(800,500);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this