开发者

on click add dynamic text area -like object in Java

开发者 https://www.devze.com 2023-03-05 02:14 出处:网络
The title is a bit confusing, but I will be using Java and Jframe. Basically, I want to be able to click anywhere on the form and have a \"text area/box\" show up (maybe use a JTextField or JTextArea

The title is a bit confusing, but I will be using Java and Jframe. Basically, I want to be able to click anywhere on the form and have a "text area/box" show up (maybe use a JTextField or JTextArea ?). I want the user to be able to edit, delete and move this string around as well.

I am thinking I need an actionlistener to listen for clicks on the form. Each click will call for a new text"box" to be created. I am not sure how to make this "box" editable, deleteable, or moveable by the user though.

I need a way to store the string and co-ordinate data too. Would it be a good idea to simply extend the JTextField or JTextArea to add c开发者_开发问答o-ordinate information to them? I see that swing is event based, so I need some kind of trigger to "save" the text (was thinking the enter key, but I realize I'd like the user to be able to enter multi-line strings).

Any thoughts would be appreciated. I am familiar with Java but only have a bit of experience with the UI portion.


Instead of an ActionListener you will need a MouseListener to track clicks.

Sounds like you need an undecorated JInternalFrame with a text box in it on JDesktopPane. However, I don't think you can create an undecorated JInternalFrame, maybe start with a normal JInternalFrame with a TextBox in it and create new frames on mouse clicks on the Desktop Pane. Then see if you can make the JInternalFrame more like a Window.

Another route is a custom component that does everything you need. This is possible, just a lot more custom code.

0

精彩评论

暂无评论...
验证码 换一张
取 消