java 画布是什么_java面板,画布,按钮

publicclassButtonTest{publicstaticvoidmain(String[]args){ButtonFrameframe=newButtonFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);}}c...

public class ButtonTest {

public static void main(String[] args) {

ButtonFrame frame = new ButtonFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}

}

class ButtonFrame extends JFrame {

public ButtonFrame() {

setTitle("计算器");

int DEFAULT_WIDTH = 0;

int DEFAULT_HEIGHT = 0;

setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);

ButtonPanel panel=new ButtonPanel();

add(panel);

}

public static final int DEFAULT_WIDTH = 400;

public static final int DEFAULT_HEIGHT = 300;

class ButtonPanel extends JPanel {

public ButtonPanel() {

JButton oneButton = new JButton("1");

JButton twoButton = new JButton("2");

JButton thrButton = new JButton("3");

JButton fouButton = new JButton("4");

JButton firButton = new JButton("5");

JButton sexButton = new JButton("6");

JButton sevButton = new JButton("7");

JButton egiButton = new JButton("8");

JButton ninButton = new JButton("9");

add(oneButton);

add(twoButton);

add(thrButton);

add(fouButton);

add(firButton);

add(sexButton);

add(sevButton);

add(egiButton);

add(ninButton);

}

}

}

谁给看一下哪错了。并改正下。就是要在一个面板上显示1-9几个按钮

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值