I'm trying to make a program thats based upon 5 Jsplitpanes and internal components, but they don't seem to get along well. Since when I run the application all the split panes are concentrated on the upper left corner
The code is really simple:
projectExplorer = new ProjectExplorer();
editorExplorer = new EditorExplorer();
favDownload = new FavDownload();
favDownloadExplorer = new FavDownloadExplorer();
//Define the listeners
addComponentListener(new ResizeListener());
horTopPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
horTopPane.setLeftComponent(projectExplorer);
horTopPane.setRightComponent(editorExplorer);
horBotPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
horBotPane.setLeftComponent(favDownload);
horBotPane.setRightComponent(favDownloadExplorer);
verticalPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
verticalPane.setTopComponent(horTopPane);
verticalPane.setBottomComponent(horBotPane);
setContentPane(verticalPane);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
resizeComponents();
}
}, 100);
the resizeComponents method is
public void resizeComponents(){
int width = getWidth();
int height = getHeight();
horTopPane.setMinimumSize(new Dimension(width, (height/2)+(height/4)));
horTopPane.setSize(horTopPane.getMinimumSize());
horBotPane.setMinimumSize(new Dimension(width, (height/8)));
horBotPane.setSize(horBotPane.getMinimumSize());
projectExplorer.setMinimumSize(new Dimension(width/8, horTopPane.getHeight()));
projectExplorer.setSize(projectExplorer.getMinimumSize());
editorExplorer.setMinimumSize(new Dimension(width/2, horTopPane.getHeight()));
editorExplorer.setSize(editorExplorer.getMinimumSize());
favDownload.setMinimumSize(new Dimension(width/8, horBotPane.getHeight()));
favDownload.setSize(favDownload.getMinimumSize());
favDownloadExplorer.setMinimumSize(new Dimension(width/2, horBotPane.getHeight()));
favDownloadExplorer.setSize(favDownloadExplorer.getMinimumSize());
}
it started just as setSize, but for some reason it didn't resize them at all, then I putted setMinimumSize and it didn't resize it either, but when i move the elements a bit on the program they all go to its minimum size, am I missing something?
I've already made a few Java GUI programs, but this one just doesn't want to work properly.
What did I do wrong?