下面的JAVA程序为什么是错误的
importjavax.swing.*;importjava.awt.*;publicclassddextendsJFrame{JPaneljp1,jp11;JLabel...
import javax.swing.*;
import java.awt.*;
public class dd extends JFrame
{
JPanel jp1,jp11;
JLabel jl1,jl2;
JPasswordField JP;
JComboBox jc;
dd()
{
jl1=new JLabel(new ImageIcon("C:/Documents and Settings/Administrator/桌面 49/图片/1.jpg"));
jl2=new JLabel();
jp1=new JPanel(new BorderLayout());
a();
jp1.add("NORTH",jl1);
jp1.add("SOUTH",jl2);
jp1.add(jp11);
add(jp1);
this.setSize(350,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setResizable (false);
}
public void a()
{
JButton jb1,jb2;
JLabel l1,l2;
l1=new JLabel("账号:");
l2=new JLabel("密码:");
jb1=new JButton("登陆");
jb2=new JButton("取消");
JP=new JPasswordField(10);
jc=new JComboBox();
jp11=new JPanel(null);
jp11.add(l1);
jp11.add(jc);
jp11.add(l2);
jp11.add(JP);
jp11.add(jb1);
jp11.add(jb2);
add(jp11);
l1.setBounds(50,14,60,20);
l2.setBounds(50,48,60,20);
jb1.setBounds(68,77,86,28);
jb2.setBounds(186,77,86,28);
jc.setBounds (115,12,168,23);
JP.setBounds (115,46,170,23);
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
new dd();
}
} 展开
import java.awt.*;
public class dd extends JFrame
{
JPanel jp1,jp11;
JLabel jl1,jl2;
JPasswordField JP;
JComboBox jc;
dd()
{
jl1=new JLabel(new ImageIcon("C:/Documents and Settings/Administrator/桌面 49/图片/1.jpg"));
jl2=new JLabel();
jp1=new JPanel(new BorderLayout());
a();
jp1.add("NORTH",jl1);
jp1.add("SOUTH",jl2);
jp1.add(jp11);
add(jp1);
this.setSize(350,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setResizable (false);
}
public void a()
{
JButton jb1,jb2;
JLabel l1,l2;
l1=new JLabel("账号:");
l2=new JLabel("密码:");
jb1=new JButton("登陆");
jb2=new JButton("取消");
JP=new JPasswordField(10);
jc=new JComboBox();
jp11=new JPanel(null);
jp11.add(l1);
jp11.add(jc);
jp11.add(l2);
jp11.add(JP);
jp11.add(jb1);
jp11.add(jb2);
add(jp11);
l1.setBounds(50,14,60,20);
l2.setBounds(50,48,60,20);
jb1.setBounds(68,77,86,28);
jb2.setBounds(186,77,86,28);
jc.setBounds (115,12,168,23);
JP.setBounds (115,46,170,23);
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
new dd();
}
} 展开
3个回答
展开全部
cannot add to layout: unknown constraint: NORTH
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jp1.add("NORTH",jl1);
jp1.add("SOUTH",jl2);
请替换成
jp1.add(BorderLayout.NORTH, jl1);
jp1.add(BorderLayout.SOUTH, jl2);
jp1.add("SOUTH",jl2);
请替换成
jp1.add(BorderLayout.NORTH, jl1);
jp1.add(BorderLayout.SOUTH, jl2);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询