实验十三:窗口设计

实验代码:

package 实验十三;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
@SuppressWarnings("serial")
class Menul extends JFrame{
JMenuBar jmb;
JMenu x1,x2,x3,x4,x5,x6;
JMenuItem t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17;
public Menul() {
jmb=new JMenuBar();
x1=new JMenu("开始");
x2=new JMenu("你的毕业学校");
x3=new JMenu("所学专业");
x4=new JMenu("想从事的职业");
x5=new JMenu("为什么想从事这份工作");
x6=new JMenu("希望去哪个地方工作");
t1=new JMenuItem("青海师范大学");
t2=new JMenuItem("青海大学");
t3=new JMenuItem("青海民族大学");
t4=new JMenuItem("网络工程");
t5=new JMenuItem("土木工程");
t6=new JMenuItem("心理学");
t7=new JMenuItem("生物学");
t8=new JMenuItem("保存");
t9=new JMenuItem("编辑");
t10=new JMenuItem("复制");
t11=new JMenuItem("粘贴");
t12=new JMenu("律师");
t13=new JMenu("公务员");
t14=new JMenu("老师");
t16=new JMenu("西宁");
t17=new JMenu("回老家");
x1.add(t8);
x1.add(t9);
x1.add(t10);
x1.add(t11);
x2.add(t1);
x2.add(t2);
x2.add(t3);
x3.add(t4);
x3.add(t5);
x3.add(t6);
x3.add(t7);
x4.add(t12);
x4.add(t13);
x4.add(t14);
x4.add(x5);
x6.add(t16);
x6.add(t17);
jmb.add(x1);
jmb.add(x2);
jmb.add(x3);
jmb.add(x4);
jmb.add(x6);
this.setJMenuBar(jmb);
this.setBounds(80, 80, 500, 400);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Menul();

}
}

实验结果:

实验心得:本次实验较难,没有加监听,只写了窗口设计。

 

转载于:https://www.cnblogs.com/Java199-wfx/p/11074060.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值