why do you want to do this way?
juse
jbutton.setVisible(false) will do

解决方案 »

  1.   

    soldier1002(廖运河) :这只是个例子;我是想用JButton遮住字,不是用字遮住
    JButton,所以用setVisible(false)不合适。
      

  2.   

    in that case, can you put the text on a label? So that you can set the label to be inVisible, It's not a good idea to block the text using button, as you will not know how long will the text be, so you can not resize your button accordingly, and the look and feel will be terrible.glad if help
      

  3.   

    soldier1002(廖运河) :这里的字实际上应该是我用g.drawLine画的线,所以难以放在Lable上。