下面的JAVA代码为什么文本框和按钮都显示不出来? 5
packageSwing;importjava.awt.Color;importjava.awt.Container;importjava.awt.Frame;impor...
package Swing;
import java.awt.Color;
import java.awt.Container;
import java.awt.Frame;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class loginnnn extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] args){
new loginnnn();
}
public loginnnn(){
Container c=new Container();
c.setLayout(null);
JPanel jpanel=new JPanel();
JButton jp=new JButton("aaa");//JPasswordField jp=new JPasswordField();
jp.setBounds(10,10,150,23);
JTextField jt=new JTextField();
jt.setBounds(20, 20, 150, 30);
c.add(jpanel);
jpanel.add(jp);
jpanel.add(jt);
c.setBackground(Color.white);
setSize(500,500);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setVisible(true);
}
} 展开
import java.awt.Color;
import java.awt.Container;
import java.awt.Frame;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class loginnnn extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] args){
new loginnnn();
}
public loginnnn(){
Container c=new Container();
c.setLayout(null);
JPanel jpanel=new JPanel();
JButton jp=new JButton("aaa");//JPasswordField jp=new JPasswordField();
jp.setBounds(10,10,150,23);
JTextField jt=new JTextField();
jt.setBounds(20, 20, 150, 30);
c.add(jpanel);
jpanel.add(jp);
jpanel.add(jt);
c.setBackground(Color.white);
setSize(500,500);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setVisible(true);
}
} 展开
1个回答
展开全部
package Swing;
import java.awt.Color;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class loginnnn extends JFrame
{
private static final long serialVersionUID = 1L;
public static void main(String[] args)
{
new loginnnn();
}
public loginnnn()
{
Container c = this.getContentPane();
c.setBackground(Color.white);
JPanel jpanel = new JPanel();
jpanel.setLayout(null);
JButton jp = new JButton("aaa");
jp.setBounds(10, 10, 150, 23);
JTextField jt = new JTextField();
jt.setBounds(20, 20, 150, 30);
jpanel.add(jp);
jpanel.add(jt);
c.add(jpanel);
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
更多追问追答
追问
也不行啊
也不行啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询