Почему Jbutton не показывает на кадре?JAVA

Программисты JAVA общаются здесь
Anonymous
Почему Jbutton не показывает на кадре?

Сообщение Anonymous »

jbutton button999 < /code> не отображается в кадре.
нет сообщения об ошибке для Button999 < /code>.
my code: < /p>

Код: Выделить всё

        JFrame frame = new JFrame("Country simulator v0.1");
frame.setDefaultCloseOperation(3);
frame.setSize(960, 600);

JButton button999 = new JButton("Add " + coin_power + " $ to the economy");
button999.setBounds(300, 300, 100, 100);
frame.add(button999);

JButton button = new JButton("Countries");
button.setBounds(10, 10, 90, 90);
frame.add(button);

JButton button2 = new JButton("Find a country egg (%s \u20ac)".formatted(eggcost));
button2.setBounds(10, 120, 240, 40);
button2.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
if (coins >= eggcost) {
coins-=eggcost;
eggs++;
eggcost *= 1.3;
}
}

});
frame.add(button2);

JButton button3 = new JButton("Open an egg (%1$s eggs left)".formatted(eggs));
button3.setBounds(10, 170, 240, 40);
button3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
frame2.setVisible(true);
}

});
frame.add(button3);

JButton button5 = new JButton("Countries you have found");
button5.setBounds(10, 220, 180, 40);
button5.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
frame3.setVisible(true);
}

});
frame.add(button5);

frame.setLayout(null);
frame.setVisible(true);
Я попытался переместить кнопку999 в нижнюю часть кода, вместо получения кнопки я ничего не получил. Отсутствующая кнопка имеет добавление * coin_power * $ в экономику


Подробнее здесь: https://stackoverflow.com/questions/794 ... w-on-frame

Вернуться в «JAVA»