Код: Выделить всё
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(500, 500);
frame.setLayout(new FlowLayout());
JTextField field = new JTextField();
field.setPreferredSize(new Dimension(100, 20));
// adding and setting visibility to false
frame.add(field);
field.setVisible(false);
JButton button = new JButton();
button.setPreferredSize(new Dimension(100, 20));
// Pointer to textfield where textfield SHOULD becoming visible once clicked
button.addActionListener(e -> field.setVisible(true));
frame.add(button);
frame.setVisible(true);
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... et-visible