package six;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Container;import java.awt.Toolkit;import java.net.URL;import javax.swing.ImageIcon;import javax.swing.JDesktopPane;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Thirteen extends JFrame{ public static void main(String[] args){ Thirteen fim=new Thirteen(); fim.setVisible(true); } public Thirteen(){ super(); setTitle("QQ 1.0"); setSize(480, 350); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); //窗口居中 setResizable(false); //背景图片 JDesktopPane desktopPane=new JDesktopPane(); getContentPane().add(desktopPane, BorderLayout.CENTER); JLabel backLabel=new JLabel(); URL res=this.getClass().getResource("TuPian 284.png"); ImageIcon icon=new ImageIcon(res); backLabel.setIcon(icon); backLabel.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); desktopPane.add(backLabel, new Integer(Integer.MIN_VALUE)); try{ desktopPane.add(Thirteen.getJlabel(),null); System.out.println("已经添加con"); }catch(Exception e){ System.out.println(e); } } public static Component getJlabel(){ //帐号块 JFrame frame=new JFrame(); Container con=frame.getContentPane(); JLabel jlabel=new JLabel("帐号 :"); jlabel.setBounds(10, 20, 50, 20); jlabel.setForeground(Color.white); JTextField jTextField=new JTextField("",50); jTextField.setBounds(70,20,100,20); //密码块 JLabel jlabel2=new JLabel("密码 :"); jlabel2.setBounds(10, 50, 50, 20); jlabel2.setForeground(Color.white); JPasswordField jPasswordField2=new JPasswordField("",50); jPasswordField2.setEchoChar('#'); jPasswordField2.setBounds(70,50,100,20); //添加进取 con.add(jlabel); System.out.println("已经添加帐号"); con.add(jTextField); con.add(jlabel2); System.out.println("已经添加密码"); con.add(jPasswordField2); System.out.println("到此一游"); return con; }}