所以我想知道如何让按钮消失。我有类似的东西......
JButton button1 = new JButton("1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
(what goes here to make it disappear?)
}
});
我还希望它让其他按钮消失,我该怎么做? 我试着这样做......
JButton button1 = new JButton("1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
share.setOnClickListener(new OnClickListener(){
public void onClick(View v){
linearlayoutbar1.setVisibility(View.GONE);
}
});
答案 0 :(得分:1)
您可以使用下一个代码:
JButton button1 = new JButton("1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button1.setVisible(false);
}
});
或者,在Java 8中使用lambda表达式,例如:
button1.addActionListener(e -> button1.setVisible(false));