Copying and Pasting Java Code in RAD Loses Your Formatting
By: Troy Campano
(2006-08-30)
Filed under Articles > Programming > Java




The Problem
Have you upgraded to IBM's RAD (Rational Application Developer) from either WSAD or Eclipse and found that when you copy and paste your java code from the editor to another application (like Microsoft Word...but really any other application) that it loses all of its formatting including font, color, side, etc? I had this problem for over a year and someone on IBM's Forums helped me solve this mystery.

The Fix
The problem here was in a bug with the specific version of Eclipse that IBM based RAD off of. With that specific version, if you have "folding" enabled then when you copy and paste your code you will lose all of your formatting. "Folding” is what allows you to ‘close’ or ‘collapse’ methods, inner classes, import statements, etc. Once you disable folding, you can copy and paste code all over the place to my hearts delight and it will retain the font formatting. To disable folding, go to your Java Editor Preferences (Window -> Preferences -> Java -> Editor -> Folding) and uncheck the "Enable folding when opening a new editor" checkbox.

I wonder if upgrading RAD will fix this. Due to my bad experiences trying to upgrade RAD though, I think I'll pass.

As always, if you have trouble, please post your comments on this web page.

~ Troy Campano ~








Reader's Comments - Add Comment


Find some of this content useful? Please consider a donation. Any donation is appreciated.