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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.