回复 楼主 hellboy
程序代码:
package import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; /** * 登录界面 * * @author Administrator * */ public class MainFrame extends JFrame { private JLabel jLabel1; private JLabel jLabel2; private JPanel jContentPane; public MainFrame() { init(); } /** * 初始化窗体 */ private void init() { this.setSize(380, 286); this.add(getJContentPane()); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(){ ImageIcon img = new ImageIcon("QQ登录界面背景2.jpg"); // 绘制面板 组件图片 protected void paintComponent(Graphics g) { g.drawImage(img.getImage(), 0, 0, this); } }; } return jContentPane; } /** * 程序入口 * * @param args */ public static void main(String[] args) { MainFrame m = new MainFrame(); } }