Hello
I have a problem how to make custom defined text area it's similar to text area which you can create in Photoshop while you wan't type any text.

Is it possible to do it in swing ?

Recommended Answers

Do you want the user to define it with a mouse drag or some other way?

Jump to Post

All 5 Replies

Do you want the user to define it with a mouse drag or some other way?

Yes, exactly !
I would like to create custom text area over the image panel.

Learn about MouseListener (start here http://download.oracle.com/javase/tutorial/uiswing/events/mouselistener.html ). You can add a MouseListener to your image panel and you can listen for mouse pressed, moue released etc. You can get the mouse position in the listener, so you will know exactly where the mouse was pressed and where it was released. These define the opposite corners of you new text area, so its easy to convert to position and size, which you can then use to create the text area exactly as you want it.

Is it possible to do transparent background of text area ? I mean text area will not cover a part of image ?

Yes.

Be a part of the DaniWeb community

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