0

Remove Error

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextField; class Gridlayout extends JFrame implements ActionListener { JButton b[]=new JButton[20]; JPanel p1,p2; JTextField t1; Gridlayout() { setTitle("calculator"); t1=new JTextField(100); Font f=new Font("arial",Font.BOLD,30); t1.setFont(f); t1.setText("0"); p1=new JPanel(); p1.setLayout(new FlowLayout(FlowLayout.LEFT,2,2)); p1.add(t1); p2=new JPanel(); p2.setLayout(new GridLayout(5,4,4,4)); for(int i=0;i<b.length;i++){ b[i]=new JButton(""+(i+1)); p2.add(b[i]); b[i].addActionListener(this); } b[9].setText("+"); b[10].setText("="); add(p1,BorderLayout.NORTH); add(p2,BorderLayout.CENTER); setSize(400,400); setVisible(true); } public static void main(String...

2nd Nov 2022, 4:52 AM
Himanshu Sharma
Himanshu Sharma - avatar
2 Respostas
0
What is your error? Have you try to start your app in debug mode with end-points ?
2nd Nov 2022, 7:02 AM
Roland
Roland - avatar
0
interface ActionListener requires to implement actionPerformed() method @Override public void actionPerformed( ActionEvent e) { } public static void main(String[] args) { new Gridlayout(); } } but layout seems to be unwished
3rd Nov 2022, 8:14 AM
zemiak