Question

pts Which layout manager constructor call would be best-suited to create a telephone keypad GUI which has three rows of three
0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.awt.*;  
import javax.swing.*;  

public class TestLayout
{  
    JFrame f;  
    MyGridLayout(){  
    f=new JFrame();  

    JButton b1=new JButton("1");  
    JButton b2=new JButton("2");  
    JButton b3=new JButton("3");  
    JButton b4=new JButton("4");  
    JButton b5=new JButton("5");  
    JButton b6=new JButton("6");  
    JButton b7=new JButton("7");  
    JButton b8=new JButton("8");  
    JButton b9=new JButton("9");  
    JButton bs=new JButton("*");  
    JButton b0=new JButton("0");  
    JButton bh=new JButton("#");  

    f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);  
    f.add(b6);f.add(b7);f.add(b8);f.add(b9);f.add(bs);  
    f.add(b0);f.add(bh);    

    f.setLayout(new GridLayout(4,3));  
    //setting grid layout of 4 rows and 3 columns  

    f.setSize(300,300);  
    f.setVisible(true);  
    }  
    public static void main(String[] args) 
    {  
        new TestLayout();  
    }  
}  

The output is

х 1 2 3 4 5 6 7 8 9 0 #

Grid Layout creates a rectangular grid of specified rows and columns.

So, the answer is

new GridLayout(4, 3)

Add a comment
Know the answer?
Add Answer to:
pts Which layout manager constructor call would be best-suited to create a telephone keypad GUI which...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT