-1

Possible Duplicate:
How to edit a text that is converted into image? or any other approach to realize/edit text

What I am trying to achieve is that... I have a text in textpane which I am converting to BufferedImage and resizing the size of the image by dragging it with mouse. Now If I want to edit the text, I am clicking on the image which hides the image and shows the text from textpane.

My problem is the size of the text in textpane is not resized(increased/decreased) as resize was done on image and not on text. So how do I change the font size as and when I resize the image containg text?

Community
  • 1
  • 1
user001
  • 961
  • 5
  • 16
  • 33

2 Answers2

2

You can adjust the font size by deriving the base font with a AffineTransform. Basically, you will need to maintain a reference to the base font that the user started with. When you need to, you would derive a new font instance by suppling a AffineTransform with the appropriate scale and apply that to the text pane

See Font#deriveFont(AffineTransform trans) for more details

MadProgrammer
  • 336,120
  • 22
  • 219
  • 344
0

Try to scale the JTextPane's content as described here http://java-sl.com/Scale_In_JEditorPane.html

Just listen resize and adapt the scale factor acordingly

StanislavL
  • 56,113
  • 9
  • 64
  • 93