コード例 #1
0
        public CenterPaneLayout(JPanel panel)
        {
            layout = new VerticalLayout(panel);

            // three main sections: top, middle, bottom
            Layout topSection = new HorizontalLayout(panel);

            topSection.setPreferredSize(100, 15);
            Layout middleSection = new HorizontalLayout(panel);

            middleSection.setPreferredSize(100, 70);

            Layout bottomSection = new HorizontalLayout(panel);

            bottomSection.setPreferredSize(100, 15);

            // three parts of the middle layout
            Layout middleLeft = new VerticalLayout(panel);

            middleLeft.setPreferredSize(15, 100);
            Layout middleMiddle = new HorizontalLayout(panel); // can be horizontal or vertical

            middleMiddle.setPreferredSize(70, 100);
            Layout middleRight = new VerticalLayout(panel);

            middleRight.setPreferredSize(15, 100);

            // set up the buttons/textview/sliders/etc for each layout
            topSection.addUIElement(new Button(34, 100));
            topSection.addUIElement(new TextEdit(33, 100));
            topSection.addUIElement(new Button(33, 100));

            middleLeft.addUIElement(new TextEdit(100, 25));
            middleLeft.addUIElement(new Slider(100, 25));
            middleLeft.addUIElement(new Button(100, 25));
            middleLeft.addUIElement(new Button(100, 25));

            middleMiddle.addUIElement(new Button(100, 100));

            middleRight.addUIElement(new TextEdit(100, 25));
            middleRight.addUIElement(new Slider(100, 25));
            middleRight.addUIElement(new Button(100, 25));
            middleRight.addUIElement(new Button(100, 25));

            middleSection.addUIElement(middleLeft);
            middleSection.addUIElement(middleMiddle);
            middleSection.addUIElement(middleRight);

            bottomSection.addUIElement(new Button(100, 100));

            layout.addUIElement(topSection);
            layout.addUIElement(middleSection);
            layout.addUIElement(bottomSection);
        }