troubleshooting Question

set button to be full width of jpanel

Avatar of ellandrd
ellandrdFlag for Ireland asked on
Java
12 Comments1 Solution596 ViewsLast Modified:
im trying to make by clear button the full width of the keypad.

by clear button is placed at the bottom in separate jpanel but i cant get it to display correctly...

private void createKeyPad() {
        setLayout( new GridLayout( 5, 4, 0, 0 ) );
       
        String[] buttonLabels = { "7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+" };
       
        for ( int i = 0; i <= 15; i++ ) {
            JButton button = new JButton( buttonLabels[ i ] );
            button.addActionListener( pro );
            add( button );
        }
       
        JPanel clearPanel = new JPanel();
        clearPanel.setLayout(null);
        JButton clearButton = new JButton( "Clear" );
        clearButton.setBounds(0, 0, 400, 50);
        clearButton.addActionListener( pro );
        clearPanel.add( clearButton );
        add( clearPanel );
    }

what type of layout will work for what im trying to do?
ASKER CERTIFIED SOLUTION
riaancornelius

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros