就是一片空白,但是你放大,缩小之后,又会出现?

解决方案 »

  1.   

    swing没做过
    友情支持
      

  2.   

    首先确认xxx.setVisible(true);进行显示了没?
    然后看看是否布局没添加正确。
    还是粘代码吧!
      

  3.   

    这是不是跟eclipse或者操作系统有关系
    我用的win7..
      

  4.   

    eclipse只是个开发工具,运行起来的事情跟他没关系
      

  5.   

    你设置的大小可能不太合适!!你用    xxx.pack 试试
      

  6.   

    代码在下面。。跟QQ登陆框差不多的。。
    package uicode;
    import java.awt.*;import javax.swing.*;public class LandBox extends JFrame{
    boxPanel bp;
       public LandBox() {
       super("山寨qq");
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setSize(350,250);
           setVisible(true);
           
           bp=new boxPanel();
           getContentPane().add(new JLabel(new ImageIcon("logo.jpg")),BorderLayout.NORTH);
           getContentPane().add(bp,BorderLayout.CENTER);
    }
       public static void main(String[] args)
       {
       new LandBox();
       }
       class boxPanel extends JPanel
       {
       boxPanel1 bp1;
       boxPanel2 bp2;
       boxPanel3 bp3;
       Color c;
       public boxPanel() {
    bp1=new boxPanel1();
    bp2=new boxPanel2();
    bp3=new boxPanel3();
    c=new Color(235,255, 255);
    setLayout(new GridLayout(3,1));
    bp1.setBackground(c);
    bp2.setBackground(c);
    bp3.setBackground(c);
    add(bp1);
    add(bp2);
    add(bp3);
    }
       }
       class boxPanel1 extends JPanel
       {
       JLabel L1;
       JLabel L2;    JTextField text;
       public boxPanel1() {
        setLayout(new FlowLayout(FlowLayout.LEFT,16,8));
    L1=new JLabel("帐号:");
    L2=new JLabel("注册新帐号");
    text=new JTextField();
    text.setPreferredSize(new Dimension(180,25));
    add(L1);
    add(text);
    add(L2); }
       }
       class boxPanel2 extends JPanel
       {
       JLabel L3;
       JLabel L4;
       JTextField text1;
       public boxPanel2() {
        L3=new JLabel("密码:");
    L4=new JLabel("找回密码");
    text1=new JTextField();
    text1.setPreferredSize(new Dimension(180,25));
     setLayout(new FlowLayout(FlowLayout.LEFT,16,0));
     add(L3);
     add(text1);
     add(L4);

    }
       }
       class boxPanel3 extends JPanel
       {
       JButton button1;
        public boxPanel3() {
    button1=new JButton(new ImageIcon("login.jpg"));
    setLayout(new FlowLayout(FlowLayout.RIGHT,20,10));
    button1.setPreferredSize(new Dimension(65,21));
    add(button1);
    }
       }
    }
      

  7.   

    因为setVisible显示之后,因为没有刷新,后添加的那些控件就没有显示出来,而调整大小时会刷新界面,于是就显示了不调换顺序的话,你在最后加一句bp.updateUI();试试看