2

I am creating an application with different look and feel! I have created a JFrame Form in Netbeans which means I have a created a class which is extended JFrame like this:

 public class interFace extends javax.swing.JFrame

And I have created a method in which I have to pass two arguments one is a frame name and other is string! so what will be the frame name of my JFrame which is extended into my class?
Method is like:

 changeLaf(JFrame frame, String laf);
4

1 回答 1

2
class MyFrame extends JFrame{

    public MyFrame() {

        changeLaf(this,"some string");
    }

    public void changeLaf(JFrame frame, String laf){
            // your code
    }

}

使用它来指代传递上面的实例。this指当前对象。它实际上并没有命名它,object或者也可以作为参考。

如果你是通过实例化类来做的,那么,

MyFrame mf = new MyFrame();
changeLaf(mf, "some string");
于 2013-08-26T10:32:01.683 回答