We investigate regular and chaotic two-dimensional (2D) and three-dimensional (3D) orbits of stars in models of a galactic potential consisting in a disk, a halo and a bar, to find the origin of boxy components, which are part of the bar or (almost) the bar itself. Our models originate in snapshots of an N-body simulation, which develops a strong bar. We consider three snapshots of the simulation and for the orbital study we treat each snapshot independently, as an autonomous Hamiltonian system. The calculated corotation-to-bar-length ratios indicate that in all three cases the bar rotates slowly, while the orientation of the orbits of the main family of periodic orbits changes along its characteristic. We characterize the orbits as regular, sticky, or chaotic after integrating them for a 10 Gyr period by using the GALI$_2$ index. Boxiness in the equatorial plane is associated either with quasi-periodic orbits in the outer parts of stability islands, or with sticky orbits around them, which can be found in a large range of energies. We indicate the location of such orbits in diagrams, which include the characteristic of the main family. They are always found about the transition region from order to chaos. By perturbing such orbits in the vertical direction we find a class of 3D non-periodic orbits, which have boxy projections both in their face-on and side-on views.