界面开发布局问题


import java.awt.*;
import java.awt.event.*;
import java.util.Date;

import javax.swing.*;

 

public class Maidanlao extends JApplet implements ActionListener{
 
 JPanel m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16;
 JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15;
 JTextField t1,t2,t3,t4,t5;
 JCheckBox p1,p2,p3,p4,p5,p6,p7,p8;
 JList s1;
 GridBagConstraints  gbc;

 
 public void init(){
  
  
  
  
  
  this.getContentPane().setBackground(Color.red);

//  g.setColor(Color.green);//设置颜色
//  g.fillRect(10,10,100,150);//画填充的矩形
  

  
  m7=new JPanel();
  m7.setLayout(new  GridLayout(4,1));
  m7.setBackground(Color.cyan);
  m1=new JPanel();
  
  
  m1.setLayout(new  GridLayout(1,3));
  
  
  Icon h1=new ImageIcon("E://workspace//作业//mc_logo.gif");
  l15=new JLabel(h1);
  
  t5=new JTextField(20);
  t5=new JTextField(20);
  l1=new JLabel("今天是:");
  
  m1.add(l15);
  m1.add(l1);

  
//  Date date = new Date();
//  System.out.println(date.getHours() + ":" + date.getSeconds() + ":" + date.getMinutes());

  m2=new JPanel();
  m3=new JPanel();
  m4=new JPanel();
  m5=new JPanel();
  m6=new JPanel();
  
  
  
  m2.setLayout(new GridLayout(3,2));
  
  
  
  
  l2=new JLabel("姓名:");
  l3=new JLabel("地址:");
  l4=new JLabel("电话:");
  
  t1=new JTextField(20);
  t2=new JTextField(20);
  t3=new JTextField(20);
  
   
  
  
   m2.add(l2);    m2.add(t1);
  
   m2.add(l3);    m2.add(t2);
  
   m2.add(l4);    m2.add(t3); 
  
  
  
  m3.setLayout(new GridLayout(3,1));
  
  l14=new JLabel();
  l15=new JLabel();
  
  l5=new JLabel("何时送餐(具体时间):");
  String arr[]={"今天","明天","后天"};
  JComboBox  jlist=new JComboBox (arr);
  m3.add(l14); m3.add(l15);
  m3.add(l5); m3.add(jlist);
  
  
  m4.setLayout(new GridLayout(1,2));
  
  l6=new JLabel("食谱(请点选):");
  t4=new JTextField(20);
  
  m4.add(l6);
  m4.add(t4);
  
  
  
  
  
  
  m5.setLayout(new GridLayout(2,4,40,10));
  
  
  p1=new JCheckBox("水果比萨") ;
 
  p2=new JCheckBox("奶酪比萨") ;
  
  p3=new JCheckBox("洋葱比萨") ;
 
  p4=new JCheckBox("土豆比萨") ;
  
  p5=new JCheckBox("火腿比萨") ;
  
  p6=new JCheckBox("鸡蛋比萨") ;
  
  p7=new JCheckBox("麻辣汉堡") ;
  
  p8=new JCheckBox("多味汉堡") ;
  
  
  
  m5.add(p1,gbc);   m5.add(p2,gbc); 
  m5.add(p3,gbc);   m5.add(p4,gbc);  
  m5.add(p5,gbc);   m5.add(p6,gbc);  
  m5.add(p7,gbc);   m5.add(p8,gbc);   
  
  
  
  m6.setLayout(new GridLayout(1,2,20,10));
  
  JButton q1=new JButton("购买");
  JButton q2=new JButton("重填");
  
  m6.add(q1);  m6.add(q2);
//  JButtonListenter bl=new JButtonListenter();
//  q1.addAncestorListener(bl);
  
  
  this.setLayout(new GridLayout(11,2));
  this.setSize(430,470);
//  this.pack();
  this.setVisible(true);
//  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  m7.add(m1);  m7.add(m2);
  m7.add(m3);  m7.add(m4);
  add(m7);  add(m5);
  add(m6);
  setLayout(new FlowLayout());
//  this.setSize(415, 550);
  
  } 
 
 
  public void paint(Graphics g){
   
  }


  public void actionPerformed(ActionEvent e) {
   System.out.println();
   
  }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值