日期:2014-05-20 浏览次数:20618 次
import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Computor { public static void main(String[] args) { new ComputorFrame(); } } class ComputorFrame extends JFrame{ JLabel jl1,jl2,jl3,jl4,jl5,jl6; public ComputorFrame(){ super("计算器"); Container container=getContentPane(); jl1=new JLabel("被乘数"); jl2=new JLabel("乘数"); jl3=new JLabel("积"); JPanel p1=new JPanel(); p1.setLayout(null); p1.add(jl1); p1.add(jl2); p1.add(jl3); jl1.setSize(50, 40); jl1.setLocation(50, 0); jl2.setSize(50, 40); jl2.setLocation(100, 0); jl3.setSize(50, 40); jl3.setLocation(150, 0); jl4=new JLabel("被除数"); jl5=new JLabel("除数"); jl6=new JLabel("商"); JPanel p2=new JPanel(); p2.setLayout(null); p2.add(jl4); p2.add(jl5); p2.add(jl6); jl4.setSize(50, 40); jl4.setLocation(50, 50); jl5.setSize(50, 40); jl5.setLocation(100, 50); jl6.setSize(50, 40); jl6.setLocation(150, 50); container.add(p1,BorderLayout.NORTH); container.add(p2,BorderLayout.SOUTH); setSize(300,300); setVisible(true); } }
import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Computor { public static void main(String[] args) { new ComputorFrame(); } } class ComputorFrame extends JFrame{ JLabel jl1,jl2,jl3,jl4,jl5,jl6; public ComputorFrame(){ super("计算器"); Container container=getContentPane(); container.setLayout(null); jl1=new JLabel("被乘数"); jl2=new JLabel("乘数"); jl3=new JLabel("积"); container.add(jl1); container.add(jl2); container.add(jl3); jl1.setSize(50, 40); jl1.setLocation(50, 0); jl2.setSize(50, 40); jl2.setLocation(100, 0); jl3.setSize(50, 40); jl3.setLocation(150, 0); jl4=new JLabel("被除数"); jl5=new JLabel("除数"); jl6=new JLabel("商"); container.add(jl4); container.add(jl5); container.add(jl6); jl4.setSize(50, 40); jl4.setLocation(50, 50); jl5.setSize(50, 40); jl5.setLocation(100, 50); jl6.setSize(50, 40); jl6.setLocation(150, 50); setSize(300,300); setVisible(true); } }