Link to home
Start Free TrialLog in
Avatar of k41d3n
k41d3n

asked on

Positioning a button pane in an existing pane

Ok, with these methods:

    /**
     * This method initializes jScrollPane3
     *
     * @return javax.swing.JScrollPane
     */
    private JScrollPane getJScrollPane3() {
        if (jScrollPane3 == null) {
            jScrollPane3 = new JScrollPane();
            jScrollPane3.setViewportView(getJPaneCheckBox());
        }
        return jScrollPane3;
    }

    private JPanel getJPaneCheckBox() {
        JPanel insidePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));  
        JPanel jPanelCheckBox = new JPanel();  
        GridLayout checkbox = new GridLayout(0, 4);
        jPanelCheckBox.setLayout(checkbox);
        try {
            Set methods = GetTestMethods
            .findMethods(DeviceIdentification.class);
            System.out.println(methods.size());
            //these variables are defined private elsewhere in the class
            //For a set or list
            for (Iterator it = methods.iterator(); it.hasNext();) {
                Object listElement = it.next();
                String element = listElement.toString();
                System.out.println(element);
                JCheckBox newCheckBox = new JCheckBox(element);
                newCheckBox.setName(element);
                System.out.println(newCheckBox.getName());
                jPanelCheckBox.add(newCheckBox);
            }
        } catch (Exception e) {
            atelog.error(e);
            e.printStackTrace();
        }
        insidePanel.add(jPanelCheckBox);
        return insidePanel;  
    }

    /**
     * This method initializes jTestbuttonPane    
     *      
     * @return javax.swing.JTestButtonPane    
     */
    private JPanel getJTestButtonPane() {
        if (jTestButtonPane == null) {
            jTestButtonPane = new JPanel();
            jTestButtonPane.setLayout(new java.awt.BorderLayout());
            JPanel jPanelHttpTestButtons = new JPanel();
            GridLayout buttons = new GridLayout(1, 2);
            jPanelHttpTestButtons.setLayout(buttons);
            JButton runAll = new JButton("Run All");
            JButton runSelected = new JButton("Run Selected");
            jPanelHttpTestButtons.add(runAll);
            jPanelHttpTestButtons.add(runSelected);
            jTestButtonPane.add(jPanelHttpTestButtons);
            jTestButtonPane.setVisible(false);
        }
        return jTestButtonPane;
    }

   /**
     * This method initializes jPanel1
     *
     * @return javax.swing.JPanel
     */
    private JPanel getJPanel1() {
        if (jPanel1 == null) {
            jPanel1 = new JPanel();
            jPanel1.setLayout(new BorderLayout());
            jPanel1.add(getJPanel(), java.awt.BorderLayout.NORTH);
            jPanel1.add(getJTabbedPane2(), java.awt.BorderLayout.CENTER);
            jPanel1.add(getJTestButtonPane(), java.awt.BorderLayout.SOUTH);
        }
        return jPanel1;
    }

It puts the button pane at the bottom of the entire GUI, I'm thinking that it would be better of the buttons were at the bottom of each checkbox grid.

but when I try to add it to the checkbox grid, it puts it to the right side of it and not below.

Is there a way to do a border layout inside a scrollpanel so that the checkboxes are at the top, and the buttons are below it?

That way they will be on any tab that has tests in it yes?
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> thePanel.add( getJTestButtonPane(), BorderLayout.SOUTH);

Of course only when needed
Avatar of k41d3n
k41d3n

ASKER

Indeed, that worked!

Thanks!
You're welcome :°)