File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JTextArea as a pop up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea as a pop up" Watch "JTextArea as a pop up" New topic
Author

JTextArea as a pop up

Priyatham Anisetty
Greenhorn

Joined: Apr 21, 2011
Posts: 15
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 .
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4540
    
    5

What happened when you tried? To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates your problem.

luck, db
There are no new questions, but there may be new answers.
Gene Dias
Greenhorn

Joined: Mar 15, 2012
Posts: 5
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

Joined: May 03, 2008
Posts: 4540
    
    5

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

Joined: Mar 15, 2012
Posts: 5
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

Joined: May 03, 2008
Posts: 4540
    
    5

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

Joined: Mar 15, 2012
Posts: 5
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

Joined: May 03, 2008
Posts: 4540
    
    5

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea as a pop up