I need to make a couple of buttons on the panel in Java Swing and, of course, I would like them to be the same size. While I stupidly instructed gaps, but it turned out some kind of nonsense. Plus, I would like to skip some space on the panel and add more buttons there, but I don’t understand how to do it.
The program code describing the panel on the right:
JPanel eastPanel = new JPanel(); eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS)); startButton = new JButton("Старт "); startButton.addActionListener(new StartButtonListener()); startButton.setSize(20, 40); stopButton = new JButton("Стоп "); stopButton.addActionListener(new StopButtonListener()); stopButton.setSize(20, 40); JButton clearButton = new JButton("Очистить"); clearButton.addActionListener(new ClearButtonListener()); clearButton.setSize(20, 40); startButton.setSize(clearButton.getSize()); stopButton.setSize(clearButton.getSize()); eastPanel.add(startButton); eastPanel.add(stopButton); eastPanel.add(clearButton); 