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
JButton,所以用setVisible(false)不合适。