Hi all 
Hab folgendes Problem. Ich hab ein JPanel pCenter und eine splitpane und möchte dass der Balken der splitpane genau in der Mitte des JPanels liegt. Siehe dazu Code einkommentierter Teil.
Jedoch wird die splitpane ganz oben und nicht in der Mitte ausgelegt. Ich weiß auch warum. Wenn ich die Höhe von pCenter ausgeben, ist sie 0.0. Warum das?
Versteh ich nicht!
[/b]
Hab folgendes Problem. Ich hab ein JPanel pCenter und eine splitpane und möchte dass der Balken der splitpane genau in der Mitte des JPanels liegt. Siehe dazu Code einkommentierter Teil.
Jedoch wird die splitpane ganz oben und nicht in der Mitte ausgelegt. Ich weiß auch warum. Wenn ich die Höhe von pCenter ausgeben, ist sie 0.0. Warum das?
Versteh ich nicht!
Code:
public class CourseCourseAnalysis extends JPanel implements GuiInterface {
private JPanel pCenter;
private JSplitPane splitPane;
CourseAnalysisGUI courseAnalysisTop;
CourseAnalysisGUI courseAnalysisBottom;
public CourseCourseAnalysis(Mainmenu mainMenu, int rid1, int rid2,
Connection con, ResourceBundle rb) {
this.mainMenu = mainMenu;
this.rb = rb;
createComponents(rid1, rid2, con);
initView();
} // StudentStudentAnalysis()
private void createComponents(int rid1, int rid2, Connection con) {
pCenter = new JPanel();
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
courseAnalysisTop = new CourseAnalysisGUI(mainMenu, rid1, con, rb);
courseAnalysisBottom = new CourseAnalysisGUI(mainMenu, rid2, con, rb);
} // createComponents()
private void initView() {
//hole die CenterPanels von den CourseAnalysisGUI-Objekten
JPanel panelTop = courseAnalysisTop.getCenterPanel();
JPanel panelBottom = courseAnalysisBottom.getCenterPanel();
//entferne die BackButtons
removeBackPanel(panelTop);
removeBackPanel(panelBottom);
splitPane.setTopComponent(panelTop);
splitPane.setBottomComponent(panelBottom);
pCenter.setLayout(new BorderLayout());
pCenter.add(splitPane, BorderLayout.CENTER);
pCenter.add(pBack, BorderLayout.SOUTH);
//----------------------------------------------
//DAS IST WICHTIG
Dimension dim = pCenter.getSize();
splitPane.setDividerLocation(dim.getHeight() / 2);
System.out.println(dim.getHeight());
//SYSTEM.OUT.PRINTLN LIEFERT 0.0! WARUM????
//----------------------------------------------
setVisible(true);
} // initView()
} // CourseCourseAnalysis()