展开全部
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();
}
}
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();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询