为了账号安全,请及时绑定邮箱和手机立即绑定

请问我想在窗口添加一个按钮怎么写

https://img1.sycdn.imooc.com//5b7a390c000189fa04770386.jpg


package com.mch0dm1n.seticom;


import javax.swing.JButton;

import javax.swing.JFrame;


public class chuangkou extends JFrame {


public chuangkou() {

this.setTitle("智伟创造");

this.setBounds(300, 200, 580, 600);

this.setSize(580, 600);

this.setLocation(300, 200);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

this.setLocationRelativeTo(null);// 为null,启动程序时窗口将置于屏幕的中央

JButton diamondsButton[][] = new JButton[6][5];//游戏按钮数组 

}


public static void main(String[] args) {

new chuangkou();

}

}


正在回答

1 回答

你的按钮没有加入到窗口中。

this.add(Button);

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

请问我想在窗口添加一个按钮怎么写

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号