本文主要是介绍洛克王国卡小游戏2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
kaijiang1.setBackground(Color.WHITE);/*去除按钮背景kaijiang1.setContentAreaFilled(false);*///添加到界面getContentPane().add(kaijiang1);}private void extracted1() {JLabel beijin = new JLabel(new ImageIcon("D:\\bc2\\kaixinge\\wendang\\2266.png"));beijin.setBounds(-8, -10, 300, 500);getContentPane().add(beijin);//给弹窗对象添加图片JLabel beijin1 = new JLabel(new ImageIcon("D:\\bc2\\kaixinge\\wendang\\资源 29527.png"));beijin1.setBounds(0, 0, 161, 171);tanchuang.getContentPane().add(beijin1);}private void extracted5() {//创建菜单对象JMenuBar tishikuaang = new JMenuBar();//创建菜单对象二级对象JMenu gn = new JMenu("功能");//创建菜单对象三级对象/*JMenuItem gyuwom = new JMenuItem ("关于我们");JMenuItem teichu = new JMenuItem ("退出");*///把三级菜单对象放到菜单二级对象gn.add(gyuwom);gn.add(teichu);//把二级菜单对象放到菜单对象tishikuaang.add(gn);//绑定动作监听 这里用方法引用gyuwom.addActionListener(this::actionPerformed);teichu.addActionListener(this::actionPerformed);//把菜单对象添加到界面setJMenuBar(tishikuaang);}private void extracted() {//设置界面大小setSize(300, 500);//设置标题setTitle("洛克王国性格模拟器");//设置关闭方式setDefaultCloseOperation(3);//设置布局为自定义setLayout(null);//让界面一直置顶setAlwaysOnTop(true);//设置设置界面居中setLocationRelativeTo(null);//设置是否可拉伸setResizable(false);//设置图标setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\bc2\\kaixinge\\wendang\\a446b83a1502cec2933a65aec324384.png")); }@Override public void actionPerformed(ActionEvent e) {Object source = e.getSource();if (source == kaijiang ){setVisible(false);new zhujiemei();}else if (source == kaijiang1 ){setVisible(false);new buzong();} else if(source == teichu ){System.exit(0);}else if ( source == gyuwom ){extracted2();}}}
这篇关于洛克王国卡小游戏2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!