import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Calc extends JFrame implements ActionListener{
JFrame frame;
JPanel textfield1,textfield2,rowpanel,calcb,mainpanel;
JTextField display;
JButton[] b;
public Calc(){
frame=new JFrame("Calculator");
textfield1=new JPanel();
textfield2=new JPanel();
display = new JTextField(16);
mainpanel = new JPanel();
textfield1.setLayout(new GridLayout(4,6));
textfield1.add(display);
textfield2.add(textfield1);
//array
String[] cbuttons = {"7","8", "9","/", "4", "5", "6","*", "1", "2", "3","+", "0", ".", "=","-"};
b = new JButton[16];
rowpanel= new JPanel();
rowpanel.setLayout(new GridLayout(4,4));
for(int c=0;c<16;c++)
{
b[c] = new JButton(cbuttons[c]);
//b[c].addActionListener(this);
rowpanel.add(b[c]);
}
//calcb.setLayout(new GridLayout(4,4));
/* for(int c=0;c<=3;c++)
{
b[c] = new JButton(cbuttons[c]);
//b[c].addActionListener(this);
row1panel.add(b[c]);
}
for(int c=4;c<=7;c++)
{
b[c] = new JButton(cbuttons[c]);
//b[c].addActionListener(this);
row2panel.add(b[c]);
}
for(int c=8;c<=11;c++)
{
b[c] = new JButton(cbuttons[c]);
//b[c].addActionListener(this);
row3panel.add(b[c]);
}
for(int c=12;c<=15;c++)
{
b[c] = new JButton(cbuttons[c]);
//b[c].addActionListener(this);
row4panel.add(b[c]);
}*/
mainpanel.setLayout(new GridLayout(5,1));
mainpanel.add(textfield2);
mainpanel.add(rowpanel);
frame.setContentPane(mainpanel);
frame.setSize(200,200);
frame.show();
frame.setResizable(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
Calc x = new Calc();
}
}
How can I Resize the BUTTONS?
It won't run because of
public class Calc extends JFrame implements ActionListener
Help.
Thanks :icon_confused: