What layout manager does i
, your LoadImageApp
instance, use? I'm betting it's not BorderLayout
. I'm betting that the LoadImageApp
class extends JPanel
and if so and if you never explicitly set its layout, then it uses a FlowLayout
by default, and as you're finding out, FlowLayout
doesn't respect the BorderLayout.EAST
int constant.
The solution is likely quite simple: make it use a BorderLayout
:
setLayout(new BorderLayout());
Edit
You state in comment:
When I set the border layout of i to EAST, my background image shifts to the right also, is there a way to get around that?
No, you're missing the point. You need to set the layout of LoadImageApp to BorderLayout. You're not supposed to add i BorderLayout.EAST. This was never recommended to you.
i.e.,
public class LoadImageApp extends JPanel {
// in the constructor
public LoadImageApp() {
setLayout(new BorderLayout());
}
// .... etc....
}
THe LoadImageApp instance (which I would name loadImageApp, not i
), should be added BorderLayout.CENTER, which you were doing before. Please read the layout manager tutorials which you can find here.