java 界面布局问题

tfish2014 2008-05-11 09:35:40
http://blog.csdn.net/tangyu477/archive/2008/05/11/2434655.aspx
...全文
133 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
甲壳虫 2008-05-12
  • 打赏
  • 举报
回复
你最好把图片放到这里来,这样才能有更多的人帮你回答,和楼上说的一样,你弄的也太麻烦了.我也懒得找图片了.
tfish2014 2008-05-12
  • 打赏
  • 举报
回复
图片没办法传过来了
只能超链接了

图片原件地址http://blog.csdn.net/tangyu477/Gallery/392555.aspx
tfish2014 2008-05-12
  • 打赏
  • 举报
回复
tfish2014 2008-05-12
  • 打赏
  • 举报
回复
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();

}

}

GRAYCAMEL 2008-05-12
  • 打赏
  • 举报
回复
你搞得太麻烦了,在这儿提问,博客里是源码,相应的gui图片却放在相册里,很多人没这个耐心! 是不是Applet太小了?
小宏 2008-05-12
  • 打赏
  • 举报
回复
????
a_nuo 2008-05-12
  • 打赏
  • 举报
回复
如果不是为了学习
可以用SWTDesinger去设计界面用SpringLayout布局管理器
SpringLayout可以实现复杂的界面布局
Inhibitory 2008-05-12
  • 打赏
  • 举报
回复
很简单的布局, 总体上用Box.createVeritcalBox(), 而每一行(或几行)再用GridLayout
tfish2014 2008-05-11
  • 打赏
  • 举报
回复
题目 实现的是一个 麦当劳订餐系统 界面开发 我遇到的问题就是布局及布不好

http://blog.csdn.net/tangyu477/archive/2008/05/11/2434655.aspx

所以就真诚的请教~!!!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧