• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

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?
0
k41d3n
Asked:
k41d3n
  • 3
1 Solution
 
zzynxSoftware engineerCommented:
>> 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?
Sure.

JPanel thePanel = new JPanel(new BorderLayout());
thePanel.add( getJPaneCheckBox(), BorderLayout.CENTER);
thePanel.add( getJTestButtonPane(), BorderLayout.SOUTH);

then:

jScrollPane3.setViewportView(thePanel);

0
 
zzynxSoftware engineerCommented:
>> thePanel.add( getJTestButtonPane(), BorderLayout.SOUTH);

Of course only when needed
0
 
k41d3nAuthor Commented:
Indeed, that worked!

Thanks!
0
 
zzynxSoftware engineerCommented:
You're welcome :°)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now