0
코드를 컴파일하려고 할 때 두 개의 동일한 오류 (제목에있는 오류)가 발생합니다. 나는 기본적으로 내가 갖고있는 예제를 복사했는데 왜 오류가 발생하는지 이해할 수 없다. 나는 아직도 자바를 배우기 때문에 나는 어떤 종류의 실수라도 사전에 사과한다 : P. 여기 코드는 다음과 같습니다오류가 계속 발생합니다. "(CLASS) 추상이 아니며 추상적 인 메서드를 무시하지 않습니다."
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ColorFactory extends JFrame {
private final int winWidth=500;
private final int winHeight=300;
private JPanel topPanel;
private JPanel bottomPanel;
private JButton redButton;
private JButton yellowButton;
private JButton orangeButton;
private JRadioButton greenRadio;
private JRadioButton blueRadio;
private JRadioButton cyanRadio;
private JLabel message;
public ColorFactory() {
setTitle("Color Factory");
setSize(winWidth, winHeight);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
topPanel=new JPanel();
bottomPanel=new JPanel();
message=new JLabel("Top buttons change the panel color and bottom radio buttons change the text color.");
add(topPanel, BorderLayout.NORTH);
add(bottomPanel, BorderLayout.SOUTH);
add(message, BorderLayout.CENTER);
}
private void topButtons(){
redButton=new JButton("Red");
orangeButton=new JButton("Orange");
yellowButton=new JButton("Yellow");
setLayout(new FlowLayout());
topPanel.setBackground(Color.WHITE);
add(redButton);
add(orangeButton);
add(yellowButton);
redButton.setBackground(Color.RED);
yellowButton.setBackground(Color.YELLOW);
orangeButton.setBackground(Color.ORANGE);
redButton.addActionListener(new ButtonListener());
orangeButton.addActionListener(new ButtonListener());
yellowButton.addActionListener(new ButtonListener());
}
private void bottomButtons(){
greenRadio=new JRadioButton("Green");
blueRadio=new JRadioButton("Blue");
cyanRadio=new JRadioButton("Cyan");
setLayout(new FlowLayout());
bottomPanel.setBackground(Color.WHITE);
add(greenRadio);
add(blueRadio);
add(cyanRadio);
greenRadio.setForeground(Color.GREEN);
blueRadio.setForeground(Color.BLUE);
cyanRadio.setForeground(Color.CYAN);
greenRadio.addActionListener(new RadioButtonListener());
blueRadio.addActionListener(new RadioButtonListener());
cyanRadio.addActionListener(new RadioButtonListener());
}
private class ButtonListener implements ActionListener{
public void actionPerfomed(ActionEvent e){
String command=e.getActionCommand();
if(command.equals("Red")){
message.setBackground(Color.RED);
}
else if(command.equals("Yellow")){
message.setBackground(Color.YELLOW);
}
else if(command.equals("Orange")){
message.setBackground(Color.ORANGE);
}
}
}
private class RadioButtonListener implements ActionListener{
public void actionPerfomed(ActionEvent i){
if(i.getSource()==greenRadio){
message.setForeground(Color.GREEN);
}
else if(i.getSource()==blueRadio){
message.setForeground(Color.BLUE);
}
else if(i.getSource()==cyanRadio){
message.setForeground(Color.CYAN);
}
}
}
public static void main(String[] args){
new ColorFactory();
}
}
여기 내가 오류의 : 사전에
error: ColorFactory.RadioButtonListener is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener
private class RadioButtonListener implements ActionListener{
^
감사합니다!
와우는 따로 따로 바보이다. 나는 또한 눈이 멀다. reposnse 주셔서 감사합니다! – Redington
이것이 도움이 되었다면 대답을 수락 할 수 있습니까? – user1339772