| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 515 人关注过本帖
标题:java添加背景,帮帮忙
取消只看楼主 加入收藏
星辰star
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-5-16
结帖率:0
收藏
 问题点数:0 回复次数:0 
java添加背景,帮帮忙
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class qq<BackgroundPanel> extends JFrame {
    private JPanel jPanel1;
    private JPanel jPanel2;
    private JPanel jPanel3;
    private ImageIcon background;
    public static void main(String[] args) {
       qq text=new qq();
       text.setLocationRelativeTo(null);
       text.setVisible(true);
    }
    private qq()
    {
        super();
        init();
    }
    private void init(){
    try{
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jPanel1 = new JPanel();
             getContentPane().add(jPanel1, BorderLayout.CENTER);
             jPanel1.setLayout(null);
             {
                // background=new ImageIcon("picture/1.png");
                 jPanel2=new JPanel(){
                 public void paintComponents(Graphics g) {
                     Image img = new ImageIcon("2.jpg").getImage();
                     super.paintComponent(g);
                      g.drawImage(img,0,0,this);
                 }
                 };
                 jPanel1.add(jPanel2);
                // jPanel2.setBackground(java.awt.Color.BLUE);
                 jPanel2.setBounds(0, 0, 300, 75);
             }
        }
        pack();
        setSize(300, 620);
    }catch (Exception e) {
        e.printStackTrace();
       }
    }
}
没有背景啊!!!高手帮忙啊
搜索更多相关主题的帖子: class background private public 
2011-12-06 20:12
快速回复:java添加背景,帮帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018091 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved