java Jtextfield没出现什么问题?

时间:2017-11-14 22:38:08

标签: java jtextfield setbounds

我有一个带有一些JTextFields的框架,但是当我执行时它没有出现 我有一个框架与一些JTextFields,但当我执行时,这不会出现 我有一个框架与一些JTextFields,但当我执行时,这不会出现 我有一个带有一些JTextFields的框架但是当我执行时它没有出现

我有一个带有一些JTextField的框架但是当我执行时没有出现

我有一个带有一些JTextField的框架但是当我执行时没有出现

import java.awt.*;  
import javax.swing.*;  
public class PanelExample {

    PanelExample()  
    {  
        JFrame f= new JFrame("Panel Example");    
        JPanel panel=new JPanel();  
        JPanel paintPane=new JPanel();  
        panel.setBounds(40,80,200,200);    
        panel.setBackground(Color.gray);  
        JButton b1=new JButton("Button 1");     
        b1.setBounds(50,100,80,30);    
        b1.setBackground(Color.yellow);   
        JButton b2=new JButton("Button 2");   
        b2.setBounds(100,100,80,30);    
        b2.setBackground(Color.green);   
        panel.add(b1); panel.add(b2);  
        f.add(panel);  

        JTextField hellopanelx0 = new  JTextField("hello world" , 20);  hellopanelx0.setBounds( 270,687,782,22 ); paintPane.add(hellopanelx0);  
        JTextField hellopanelx1 = new  JTextField("hello world" , 20);  hellopanelx1.setBounds( 270,643,782,21 ); paintPane.add(hellopanelx1);  
        JTextField hellopanelx2 = new  JTextField("hello world" , 20);  hellopanelx2.setBounds( 270,665,782,21 ); paintPane.add(hellopanelx2);  
        JTextField hellopanelx3 = new  JTextField("hello world" , 20);  hellopanelx3.setBounds( 270,710,782,21 ); paintPane.add(hellopanelx3);  
        JTextField hellopanelx4 = new  JTextField("hello world" , 20);  hellopanelx4.setBounds( 270,732,782,21 ); paintPane.add(hellopanelx4);  
        JTextField hellopanelx5 = new  JTextField("hello world" , 20);     hellopanelx5.setBounds( 1054,262,334,44 ); paintPane.add(hellopanelx5);  
        JTextField hellopanelx6 = new  JTextField("hello world" , 20);    hellopanelx6.setBounds( 382,419,335,21 ); paintPane.add(hellopanelx6);  
        JTextField hellopanelx7 = new  JTextField("hello world" , 20);  hellopanelx7.setBounds( 382,442,335,21 ); paintPane.add(hellopanelx7);  
        JTextField hellopanelx8 = new  JTextField("hello world" , 20);  hellopanelx8.setBounds( 942,442,334,21 ); paintPane.add(hellopanelx8);  
        JTextField hellopanelx9 = new  JTextField("hello world" , 20);  hellopanelx9.setBounds( 942,464,334,21 ); paintPane.add(hellopanelx9);  
        JTextField hellopanelx10 = new  JTextField("hello world" , 20);  hellopanelx10.setBounds( 158,687,111,22 ); paintPane.add(hellopanelx10);  

        f.setSize(4000,4000);    
        f.setLayout(null);    
        f.setVisible(true);    
    }

    public static void main(String args[])  
    {  
        new PanelExample();  
    }  
}

这是我的新代码

   import java.awt.*;  
    import javax.swing.*;  
    public class PanelExample {  
        PanelExample()  
          {  
          JFrame f= new JFrame("Panel Example");    
          JPanel panel=new JPanel();  
           JPanel paintPane=new JPanel();  
          panel.setBounds(40,80,4000,4000);    
          panel.setBackground(Color.gray);  
           JButton b1=new JButton("Button 1");     
          b1.setBounds(50,100,80,30);    
          b1.setBackground(Color.yellow);   
         JTextField hellopanelx0 = new  JTextField();
        hellopanelx0.setBounds( 270,687,782,22 );
        panel.add(hellopanelx0);  
      JTextField hellopanelx1 = new  JTextField("hello world" , 20);
        hellopanelx1.setBounds( 270,643,782,21 );
     paintPane.add(hellopanelx1);  
      JTextField hellopanelx2 = new  JTextField("hello world" , 20);  
     hellopanelx2.setBounds( 270,2665,782,21 );
      panel.add(hellopanelx2);  
         JButton b2=new JButton("Button 2");   
        b2.setBounds(100,100,80,30);    
        b2.setBackground(Color.green);   
        panel.add(b1); panel.add(b2);  
        f.add(panel);  



  JTextField hellopanelx3 = new  JTextField("hello world" , 20);    hellopanelx3.setBounds( 270,710,782,21 ); panel.add(hellopanelx3);  
    JTextField hellopanelx4 = new  JTextField();  hellopanelx4.setBounds( 270,732,782,21 ); panel.add(hellopanelx4);  
   JTextField hellopanelx5 = new  JTextField();  hellopanelx5.setBounds( 1054,262,334,44 ); panel.add(hellopanelx5);  
  JTextField hellopanelx6 = new  JTextField();  hellopanelx6.setBounds( 382,419,335,21 ); panel.add(hellopanelx6);  
     JTextField hellopanelx7 = new  JTextField("hello world" , 20);  hellopanelx7.setBounds( 382,442,335,21 ); panel.add(hellopanelx7);  
           JTextField hellopanelx8 = new  JTextField("hello world" , 20);  hellopanelx8.setBounds( 942,442,334,21 ); panel.add(hellopanelx8);  
        JTextField hellopanelx9 = new  JTextField("hello world" , 20);  hellopanelx9.setBounds( 942,464,334,21 ); panel.add(hellopanelx9);  
   JTextField hellopanelx10 = new  JTextField("hello world" , 20);  hellopanelx10.setBounds( 158,687,111,22 ); panel.add(hellopanelx10);  

                f.setSize(4000,4000);    
                f.setLayout(null);    
                f.setVisible(true);    
        }  
        public static void main(String args[])  
        {  
        new PanelExample();  
        }  
    }  

0 个答案:

没有答案