I tried your code out.
I had to add some import statements to get it to compile:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class PasswordBox extends JFrame
I invoked the class from another java source as follows:
import javax.swing.*;
public class Test extends JFrame{
public Test(){
}
public static void main (String[] args){
Test test = new Test();
test.init();
}
public void init(){
PasswordBox box = new PasswordBox();
box.show();
}
}