I am having a problem with my code. For some reason, it won't show my second button b2, and I can't set the size for the first button. I want to have both buttons next to each other in the middle with some space around them.
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
public class HW10{
Button b1, b2;
L1 l1;
class L1 implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
int tmp = Integer.parseInt(b1.getLabel());
tmp++;
b1.setLabel(""+tmp);
}
}
public HW10(){
JFrame frame = new JFrame("Homework 15");
l1 = new L1();
b1 = new Button("0");
b2 = new Button("KURAC");
b1.addActionListener(l1);
b1.setBounds(100, 100, 100, 80);
frame.add(b1);
frame.setBounds(200,200,400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) {
HW10 kk = new HW10();
}
}
