Java Swing: alignment of right element in JSplitPane -


for programming exercise using jsplitpane make window nice render of fractal on right, , other garbage on left. however, have come across strange issue: left element fine, right element left aligned. far can tell, right element given size of right part of screen, it's left, left element on top of it.

i create jsplitpane , add elements this:

splitpane = new jsplitpane(jsplitpane.horizontal_split, true);  splitpane.add(sidebar, jsplitpane.left); splitpane.add(fractalwindow, jsplitpane.right);  frame.add(splitpane); 

i've tried many different ways of constructing jsplitpane , adding components (using setleftcomponent , setrightcomponent, etc), whatever do, both components left aligned. doing wrong?

edit: sidebar jpanel, fractalwindow subclass of jpanel. i've tried adding fractalwindow jpanel , adding splitpane, right component not drawn @ all. have not specified layout jframe frame.

edit 2: it's solved. fractal class using methods getx() , gety() , didn't know overriding these. both return 0, meant jpanel put in top left corner of parent component.

you can try put jpanel in right side, , place whatever want of jpanel:

splitpane = new jsplitpane(jsplitpane.horizontal_split, true);  splitpane.add(sidebar, jsplitpane.left); jpanel panel = new jpanel(); panel.add(fractalwindow,borderlayout.center); splitpane.add(panel, jsplitpane.right);  frame.add(splitpane); 

that way, panel aligns put in center, , split pane puts panel on right.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -