views:

74

answers:

2

Hello everyone. I have a little problem.

Class ll:

interface jj{
    public class ll implements gg{
    public static String j ="C:\\";
        //some code here
}
}

Class 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
}
}

CLass 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);
        }
}
}

My problem is, that text field printing doesn't work. I tryed to System.out.println the jj.ll.j string to test if it has something. and yes it has and works how expected.

+1  A: 

I'm a little surprised that the compiler lets you do that--but unless you are just curious, don't do this.

Just find another way.

Added complexity is never worth it.

Bill K
+4  A: 

I don't get the logic of making a class inside an interface.

If you need the j string in various classes, just declare it as a public static field in some class. Implementing an interface to get a constant is quite old fashioned. If you use Java 1.5+, do a static import.

PhiLho
I don't really get how to do a static import. Could you please give an example.
UPD: thanks i found it at oracle documentation