title: Java Swing: alignment of right element in JSplitPane
body: <p>For a programming exercise I am using a JSplitPane to make a window with a nice render of a fractal on the right, and some other garbage on the left. However, I have come across a very strange issue: the left element is completely fine, but the right element is also always left aligned. As far as I can tell, the right element is given the size of the right part of the screen, but it's always fully to the left, with the left element over top of it.</p>
  
  <p>I create the JSplitPane and add its elements like this:</p>
  
  <pre><code>splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
  
  splitPane.add(sidebar, JSplitPane.LEFT);
  splitPane.add(fractalWindow, JSplitPane.RIGHT);
  
  frame.add(splitPane);
  </code></pre>
  
  <p>I've tried many different ways of constructing the JSplitPane and adding components to it (using setLeftComponent and setRightComponent, etc), but whatever I do, both components are always left aligned. What am I doing wrong?</p>
  
  <p>EDIT: sidebar is a JPanel, fractalWindow is a subclass of JPanel. I've tried adding fractalWindow to another JPanel and adding that to splitPane, but then the right component is not drawn at all. I have not specified a layout for JFrame frame.</p>
  
  <p>EDIT 2: it's solved. My <code>Fractal</code> class was using methods <code>getX()</code> and <code>getY()</code> and I didn't know that I was overriding these. They would usually both just return 0, which meant that the JPanel was always put in the top left corner of the parent component.</p>