Java 프로그램을 작성하는 동안 몇 가지 JPanels에서 동일한 메서드 세 개를 사용하여 나 자신이 일부 typing을 생략하고 JPanel을 이러한 메서드 만 포함 된 추상 클래스로 확장 한 다음, 내 패널에 추상 수업?상속 된 JPanel 프로그램을 잠그기
예, 프로그램은 현재 정확히 아무것도 수행하지 않습니다. 윈도우를 표시하지도 않고 NetBeans에 따르면 일반적으로 12 개가 넘는 반면 2 개의 스레드 만 실행합니다.
다음은 추상 클래스는 다음과 같습니다
import ControlClasses.MainWindow;
import ControlClasses.MethodLibrary;
import java.awt.Component;
public abstract class CustomPanel extends javax.swing.JPanel {
protected MainWindow parent;
protected MethodLibrary library;
/**
* Sets the owner of this panel for the purpose of method calls.
* @param parentFrame The JFrame this panel is located on.
*/
public void setParent(MainWindow parentFrame){
this.parent = parentFrame;
}
/**
* If the panel is on a JLayeredField, this can be used to disable all components
* in order to prevent user input from reaching this panel instead of the intended one.
* @param mode The state to set all controls to.
*/
public void changeFunctionality(boolean mode){
for(Component comp : this.getComponents()){
comp.setEnabled(mode);
comp.setVisible(mode);
}
}
/**
* Adds the method library to the class.
* @param library The library's handle.
*/
public void addLibrary(MethodLibrary library){
this.library = library;
}
}
내가 여기서 뭔가를 놓친 건가?
나는 당신의 문제가 다른 곳에있을 것을 제안하고 싶다 ... – MadProgrammer
아마 문제는 아니지만 시각적 인 혼동을 피하고 컴파일러를 좀더 엄격하게 (그리고 가능한 문제를 지적하기 위해)'@ Override'를 사용해야한다. 클래스를 확장 할 때 주석. – SnakeDoc
여기에 뭔가 빠졌습니까? - 예 [MCVE] (http://stackoverflow.com/help/mcve), 짧은, runnable, compilable 및 실제 대답은 내가 거기에 대한 기대 목표에 대한 설명 – mKorbel