• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JTextArea as a pop up

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am wondering if I can Pop up a JTextArea as PopUp , so the user will be able to edit the text in the textarea.


Thanks in Advance .
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened when you tried? To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates your problem.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The short answer is yes. Here is a sample:

This will create button on the menuBar that pops up a modal dialog box that contains a JTextArea. Of course, you'll need to set your bounds etc.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Priyatham Anisetty wrote:Hi I am wondering if I can Pop up a JTextArea as PopUp



Gene Dias wrote:The short answer is yes. Here is a sample:



The question was about using a popup, not a modal JDialog. Apart from that, please DontBeACodeMill <- link

edit

Gene Dias wrote:you'll need to set your bounds etc.


No! Use an appropriate layout manager.
 
Gene Dias
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you prefer the long answer, but you don't want me to be a CodeMill. A Popup object does not allow a user to edit the JTextArea, but there are several ways to get a Pop Up, popup or PopUp without it being of type javax.swing.Popup. One is a JDialog. If you want to keep the focus on the pop up until the user is done entering the text, you can set modal, but that is simply an option. In my sample, I did not set any layout manager, size, text, etc. that I leave for you.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gene Dias wrote:So you prefer the long answer


Depends what you mean by 'the long answer'

Gene Dias wrote:but you don't want me to be a CodeMill.


Did you go through the link to find why?

Gene Dias wrote:A Popup object does not allow a user to edit the JTextArea


Wrong. It does not by default allow the user to edit the JTextArea. Changing that behavior is just a matter of invoking the relevant methods. One method, actually.

Gene Dias wrote:but there are several ways to get a Pop Up, popup or PopUp without it being of type javax.swing.Popup. One is a JDialog.


I wouldn't classify a JDialog as a popup. JPopupMenu, maybe. But the question was about Popup misspelled PopUp, and my initial response was appropriate to the question and could elicit some clarification and a better framed question, benefiting Priyatham in the process.

Your copy/pastable code snippet was akin to spoonfeeding, which is why I pointed you to the FAQ page.

Gene Dias wrote:If you want to keep the focus on the pop up until the user is done entering the text, you can set modal, but that is simply an option.


Not really relevant, but OK.

Gene Dias wrote:In my sample, I did not set any layout manager, size, text, etc. that I leave for you.


I quote you again:

you'll need to set your bounds etc.


That isn't a suggestion to use an appropriate layout manager.

Moreover, your code snippet retains the default BorderLayout of the JDialog, and setBounds(...) would be ineffective.
 
Gene Dias
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I learned something. I didn't realize you could edit inside a Popup, but now I realize you have to have the Popup within the Application's window, then it will allow you to edit it. By default it does allow you to edit the textArea, but only if the Popup is positioned correctly.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gene Dias wrote:Well I learned something.


Isn't that what forums are for?

Gene Dias wrote:I didn't realize you could edit inside a Popup, but now I realize you have to have the Popup within the Application's window, then it will allow you to edit it.


I didn't know that, so I've learned something too.

Gene Dias wrote:By default it does allow you to edit the textArea, but only if the Popup is positioned correctly.


That's not a constraint.
One -- to the text area
Two
Three -- check not null
Four -- set true
 
It was the best of times. It was the worst of times. It was a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic