약간의 문제가 있습니다.자바 인터페이스 구현 문제
클래스가있다 :
interface jj{
public class ll implements gg{
public static String j ="C:\\";
//some code here
}
}
클래스 GGG :
interface gg{
public class ggg extends JFrame implements jj{
//bunch of code + a textfield
textField = new JTextField();
textField.setBounds(72, 120, 217, 20);
textField.setColumns(10);
//bunch of code
}
}
클래스 AAA
public class aaa implements jj, gg {
public aaa(){
//File chooser here + editing strin "j" from class "ll"
File f = chooser.getSelectedFile();
if(f!=null)
{
jj.ll.j = f.getPath();
//And printing "j" string to the text field from ggg class
gg.ggg.textField.setText(jj.ll.j);
}
}
}
내 문제는, 텍스트 필드 인쇄가 작동하지 않습니다. 나는 System.out.println에 jj.ll.j 문자열을 테스트 해보기로했다. 네, 예상대로 작동하고 있습니다.
인터페이스 내에 클래스가 필요합니까? – stacker
제 조언은 비 인터페이스 클래스를 인터페이스 내에 포함시키지 않는 것입니다. – Powerlord
3 개의 다른 클래스에서 j 문자열을 사용해야합니다. 자바가 멀티 상속 기능을 제공한다면 훨씬 더 쉬울 것이다.하지만 우리는 가지고있는 것을 가지고있다. – artouiros