1 Reply Latest reply on May 8, 2012 3:01 PM by gimbal2

    Aligning JPanel

      Greetings all,

      I am rather new to swing and I encountered a problem that I cannot seem to understand, I found many other threads throughout the net of people with similar problems, but their solution wasn't really what I needed.

      I have a JFrame, that has a JPanel (with Card layout) as contentPane. Inside the JPanel I am placing components.
      I placed a label, and set it to setAlignmentX(CENTER_ALIGNMENT) and it worked fine.
      However when I try to add another JFrame to it (BoxLayout), and I do setAlignmentX(LEFT_ALIGNMENT), it aligns the panel to the right and not the left, and if I do RIGHT_ALIGNMENT, it aligns it to the left. Obviously when I say it aligns to I mean to my sides, or rather the screen sides from an observer point, I considered for a moment whether it might be just too sophisticated and it means the screen sides from the scren Point of View, but as nothing else I ever heard of works like that, I don't suppose that's it. heh.

      While I guess I can stay with the RIGHT_ALIGNMENT, I'd much rather understand what the problem is and how to fix it.

      Can anyone shed some light on this?
      A lot of thanks.

        • 1. Re: Aligning JPanel
          Not like this. Better create a small example program that demonstrates the problem. Btw I assume that this:
          However when I try to add another JFrame to it (BoxLayout),
          is a typo and you meant to say JPanel.