Я получаю сообщение об ошибке «Кнопка конструктора (String, int, Font, Font, Color, Color) не определена» в строках параметров [0], [1] и [2] , и я довольно застрял в данный момент!
В for-l oop я получаю сообщение «Метод setSelected (boolean) не определен для типа Button».
Как создать простую кнопку с помощью команды "import java .awt.Button;" библиотека?
Класс меню
import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import me.nielsen.firestorm.utils.Fonts;
public class Menu {
private final Button[] options;
private int currentSelection;
private final Font font1 = new Font("Arial", Font.PLAIN, 32);
private final Font font2 = new Font("Arial", Font.BOLD, 48);
public Menu() {
options = new Button[3];
options[0] = new Button("Play", 200 + 0 * 80, font1, font2, Color.WHITE, Color.YELLOW);
options[1] = new Button("Options", 200 + 1 * 80, font1, font2, Color.WHITE, Color.YELLOW);
options[2] = new Button("Exit", 200 + 2 * 80, font1, font2, Color.WHITE, Color.YELLOW);
// new Button(text, textY, font, selectedFont, color, selectedColor, selected)
}
public void render(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, Firestorm.WIDTH, Firestorm.HEIGHT);
Fonts.drawString(g, new Font("Arial", Font.BOLD, 72), Color.ORANGE, Firestorm.TITLE, 80);
for(int i = 0; i < options.length; i++)
if(i == currentSelection)
options[i].setSelected(true);
else options[i].setSelected(false);
options[i].render(g);
}
}