면책 조항, 이것은 숙제입니다. 저를 올바른 방향으로 가르쳐주십시오.AWT 패널을 사용하여 정적 중첩 클래스 드롭 다운 목록
중첩 된 클래스에 문제가 있습니다. 기본적으로 java.awt Panel을 통해 드롭 다운 목록을 생성하는 중첩 된 정적 클래스를 만들어야합니다. (내 코드에 약간의 업데이 트 ... 여전히 '그래도 혼동)
package ui.panels;
import interfaces.Resettable;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import shapes.Shape;
import model.Model;
public class MainPanel extends Panel implements Resettable{
ActionPanel actionPanel;
ControlsPanel controlsPanel;
private ColorPanel colorPanel;
private void init() {
colorPanel = new ColorPanel();
}
public MainPanel(Model model) {
actionPanel = new ActionPanel(model);
controlsPanel = new ControlsPanel(model);
setLayout(new GridLayout(2,1));
add(controlsPanel);
add(actionPanel);
}
public void resetComponents() {
controlsPanel.resetComponents();
actionPanel.resetComponents();
}
public static class ColorPanel {
public final static String BLACK = "Black";
public final static String BLUE = "Blue";
public final static String GREEN = "Green";
public final static String RED = "Red";
public final static String YELLOW = "Yellow";
public final static String Magenta = "Magenta";
private static String[] color_selections = {"Black","Blue","Green","Red","Yellow","Magenta"};
String msg = "";
// now create list panel
public ColorPanel(){
Choice myChoice = new Choice();
for (String msg : color_selections) {
myChoice.add(msg);
}
myChoice.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
//do something here when item is selected
}
});
this.add(myChoice); //here is my problem. I don't know what this should say
}
}
}
는 "문제가있다". 문제를 설명하는 것이 너무 많을까요? – meriton
필자는이 서식을 지정했습니다 (가능한 경우 코드 서식을 지정해야합니다). 대괄호가 맞는지 확실하지 않습니다. 제목의 요점이라고 생각할 때 확인하십시오. –
정확한 오류 메시지를 게시하십시오 - "문제가 있습니다"가 부족합니다. –