1

Как удалить кнопку с фрейма?

JFrame frame = new JFrame();
JButton button = new JButton();
frame.getContentPane().add(BorderLayout.SOUTH, button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVizible(true);

А теперь, как мне удалить кнопку из фрейма?

1
  • 1
    frame.getContentPane().remove(button); 8 фев 2017 в 9:54

2 ответа 2

1

Используем метод remove:

frame.remove(button);

или

button.getParent().remove(button);
0

Используй Remove:

panel.remove(button);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.