The incident occurred on Sunday in the city of Doboj, after 25-year-old Miroslav Milic visited 18-year-old Daniela's house, where her mother and stepfather also live.
The man left the place the next morning and returned shortly after, with a grenade launcher and an automatic rifle he had kept in his home.
He fired from several grenades at the house, and then started shooting at the building with the automatic rifle.
The ex-girlfriend was unharmed in the attack, but her parents were injured and later hospitalized.
Doctors said their lives are not in danger. The attacker was arrested by police.
Daniela's stepfather told police that Daniela and Miroslav had separated after living together for three months. On Sunday, Miroslav came to Daniela's house, but failed to persuade his ex-girlfriend come back to live with him.