ISE-SHIMA, Japan (Reuters) - U.S. President Barack Obama disparaged U.S. Republican presidential candidate Donald Trump on Thursday, saying the billionaire seeks tweets over solutions and has “rattled” foreign leaders with his pronouncements.

Obama accused the real estate mogul and former reality TV impresario of making cavalier comments for provocative effect, and he urged all presidential candidates to take the high road in a boisterous and harsh campaign.

Weighing in on the race to succeed him with his strongest broadside yet against Trump, Obama said fellow leaders from the Group of Seven nations “are surprised by the Republican nominee”.

“They are not sure how seriously to take some of his pronouncements but they are rattled by them,” the president told a news conference on the sidelines of a G7 summit in central Japan.

“For good reason, because a lot of the proposals he has made display either ignorance of world affairs or a cavalier attitude, or an interest in getting tweets and headlines, instead of actually thinking through what it is that is required to keep America safe, secure and prosperous and the world on an even keel.”

Many U.S. allies fear Trump will feed insecurity in countries worried about China’s growing power, embolden nationalists and authoritarians, and unravel Obama’s “pivot” to the Asia-Pacific.

Trump has also been accused of racism and bigotry for saying he would build a wall to keep out illegal Mexican immigrants and would temporarily ban Muslims from the United States. He has also made comments considered demeaning to women.

The race between Trump on the one hand and the Democratic candidates, front-runner Hillary Clinton, a former secretary of state, and Senator Bernie Sanders, for the Nov. 8 election has become increasingly bitter and personal.

Trump this week took his use of accusations against Clinton to levels unprecedented in modern U.S. presidential campaigns, making incendiary statements that television networks cannot resist covering, giving him hours of free media and putting his opponents on the defensive.

Obama said it was natural for journalists in such a campaign to elevate “every roll, blink, speed bump, conflict, trash talkin’”, but urged, instead, that candidates from both sides stick to the issues.

“Grumpiness arises where folks feel that we’re not talking about issues but personalities or character.”

Obama, a Democrat, issued his most extensive analysis to date of his own party’s race, while refusing to take sides.

He rejected a suggestion that beating Trump would get more difficult as the two parties’ conventions approach in July, a period when the Democratic victor can focus on fighting Trump instead of the fellow Democrat, adding that the Democrat battle was tough.

“Arguing against your friends is more draining than arguing against political opponents,” Obama said.

He said there were no big ideological differences between Clinton, an establishment candidate who is a former First Lady and senator, and Sanders, a firebrand populist who identifies as a Democratic Socialist.

The president said it was important that the race eventually end in a way “that leaves both sides feeling proud of what they’ve done.”