Tom Hanks' surprise announcement that he has type 2 diabetes shines a spotlight on the important role that weight--including yo-yo dieting--can play in developing this condition.

The 57-year-old actor has repeatedly gained and lost weight for convincing on-screen portrayals.

In 1992, he reportedly put on 30 pounds for his role as the alcoholic baseball-team manager Jimmy Dugan in "A League of Their Own." A year later his weight was way down to portray an AIDS-ravaged attorney in "Philadelphia," a role for which he earned an Oscar.

And in 2000, he shed 50 pounds for his Oscar-nominated role in "Cast Away."

"The gaining and the losing of weight may have had something to do with [developing diabetes] because you eat so much bad food and you don’t take any exercise when you're heavy," Hanks said at a London press conference to promote his newest movie, "Captain Phillips."

Gaining and losing weight in and of itself isn't a typical cause of type 2 diabetes, but it can contribute, says Etie S. Moghissi, MD, associate clinical professor of medicine at the University of California, Los Angeles and a past vice president of the American Association of Clinical Endocrinologists.

Being overweight or obese on their own are well-known risk factors for type 2 diabetes. (But not type 1 diabetes, a different condition caused by an autoimmune attack on blood sugar-regulating cells).

"The risk of getting diabetes increases as we gain weight," says Moghissi. And a history of weight extremes may actually contribute to being heavier in the long run.

In one study, women who had experienced more fluctuations in their weight over their lifetime were an average of almost 20 pounds heavier than women who had not experienced these highs and lows.

Being heavy contributes to developing insulin resistance, one of the hallmarks of diabetes. Insulin is a hormone that is needed to move sugar out of the blood stream. Diabetes develops when the body doesn't respond as well as it should to the hormone or if the pancreas doesn't produce enough insulin or both.

But many other factors can also contribute to diabetes, including age, genetics, high blood pressure, high cholesterol, erratic eating habits, and even lack of sleep, says Moghissi. Hanks told David Letterman this week that he has had high blood sugar for 20 years, a condition which put him at higher risk for developing diabetes.

Like the rest of us, Hanks isn't getting any younger. He also believes he may have had a genetic predisposition to the disease.

Losing weight and keeping it off are certainly key to successfully managing type 2 diabetes once you've been diagnosed.

"If you're overweight, you need to change your lifestyle, eat right, and exercise and lose the weight slowly and keep it down rather than going on extreme diets," says Moghissi.

Some people actually manage to control their diabetes through lifestyle measures alone, namely eating right, maintaining a healthy weight, and exercising.

Hanks looked trim on Letterman and in his newest role as Captain Phillips. Keeping that look will be central to maintaining his health from here on in.

The two-time Oscar winner has sworn off any future roles that might involve a more portly appearance than the one he sported on Letterman.

Gaining weight, he told reporters, is "more or less a young man's game. I'm 57 and I don't think I'm going to take on any job--or even go on any vacation again--and see to it that I can gain 30 pounds."