Reputation: 371
I am making an application that show the information I entered in a textfield, combo box, etc.. into a text area.
I want to hide the text area when I started up the application and when I press on a button I want to show with the desired information.
I've tried to place <nameOfTextArea>.setVisible(false);
in the frame constructor, but it is still visible.
How can I start up the frame without seeing this text area?
Constructor frame:
public StudentInfoFrame() {
initComponents();
textAreaVoorOpslaanInfo.setVisible(false);
}
My button in the frame:
private void uitvoerButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
..... Variables here .....
textAreaVoorOpslaanInfo.setVisible(true);
textAreaVoorOpslaanInfo.append("Voornaam: \t\t" + voornaam + "\n"
+ "Achternaam: \t\t" + achternaam + "\n"
+ "E-mail adres: \t\t" + email + "\n"
+ "Geboortedatum: \t" + geboortedatum + "\n"
+ "Lengte: \t\t" + lengte + "m\n"
+ "Gewicht: \t\t" + gewicht + "kg\n"
+ "Geslacht: \t\t" + geslacht + "\n"
+ "Vooropleiding(en): \t" + vooropleiding + "\n"
+ "Uitwonend: \t\t" + uitwonend);
} catch (Exception e){
System.out.println(e);
}
}
Upvotes: 0
Views: 3393
Reputation: 1
Try this one:
textAreaVoorOpslaanInfo.hide();
or this:
textAreaVoorOpslaanInfo.show();
Upvotes: 0
Reputation: 46841
Call JComponent#revalidate() on parent component after changing element's visibility.
Call JFrame#setVisible(true)
in the end after adding all the components.
Upvotes: 0
Reputation: 371
My question is solved. The jTextArea was invisible, but the jScrollPane was not.
Made the jScrollPane invisible in the constructor and it worked as intended.
Thanks for the help from the people above this post.
Upvotes: 2