在java图形界面中如何删除已定义的标签

如果可以请举个例子说明一下,谢谢了~
2024-12-05 18:26:15
推荐回答(2个)
回答1:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;

public class LabelDelTest extends JFrame implements ActionListener {
JLabel label;
JButton button;
public LabelDelTest() {
label = new JLabel("新建标签陆桥"派培,JLabel.CENTER);
label.setBorder(new TitledBorder(""));
button = new JButton("删尘悉唯除标签");
button.addActionListener(this);
add(label,"North");
add(button,"South");
setTitle("标签删除");
setBounds(200,100,500,300);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {

new LabelDelTest();
}

public void actionPerformed(ActionEvent e) {
remove(label);
this.repaint();
}

}

回答2:

你是要隐藏吗?用jquery中的hide()行吗?