Topic: 我的按钮名称哪去了那????

  Print this page

1.我的按钮名称哪去了那???? Copy to clipboard
Posted by: pnwqcomputer
Posted on: 2005-07-15 21:55

以下代码
import javax.swing.*;
import java.awt.*;

public class Counter extends JFrame{
private JButton mc,mr;

public Counter(){
super("计算器");
Container c = getContentPane();
c.setLayout(null);

mc=new JButton("MC");
mc.setForeground(Color.red);
mc.setSize(35,25);
mc.setLocation(5,55);
c.add(mc);

mr=new JButton("MR");
mr.setForeground(Color.red);
mr.setSize(40,40);
mr.setLocation(70,90);
c.add(mr);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(258,238);
setResizable(false);
setVisible(true);
}
public static void main(String args[]){
Counter frame=new Counter();
}
}

运行后按钮名称不见了,请大虾们指点下!!!谢谢!!!!

2.Re:我的按钮名称哪去了那???? [Re: pnwqcomputer] Copy to clipboard
Posted by: pnwqcomputer
Posted on: 2005-07-16 09:06

自己顶上去先!!!

3.Re:我的按钮名称哪去了那???? [Re: pnwqcomputer] Copy to clipboard
Posted by: Jayzz
Posted on: 2005-07-17 16:07

你使用的是Null布局, 所以控件的大小都得由你自己控制.
如果按钮的名称不见了, 应该是按钮的size不够. 重新设置该按钮的size应该可以解决这个问题.

4.Re:我的按钮名称哪去了那???? [Re: pnwqcomputer] Copy to clipboard
Posted by: pnwqcomputer
Posted on: 2005-07-20 08:44

谢谢!!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923