Hey guys! I created a dialog box the prompts the user to input a name. I want that name to be displayed in a textarea. How do I accomplish this? And is displaying it in a textarea right or do I use something else like say a textpane?
Here's my code btw:
Here's the the MouseClicked event. When the user clicks in the scrollpane, this pops up.

private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {
String str = JOptionPane.showInputDialog(null, "Enter tag: ");
  if(str != null)
  JOptionPane.showMessageDialog(null, "You entered the tag : " + str);
}

I'm not sure event should I use under the textarea in order for the input to display. Btw, I'm using NetBeans. Thanks guys!

You could use a text component, but if you don't expect the user to edit it in place, then a simple JLabel will work just fine. You display text in it by something as simple as
myJLabel.setText(str);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.