Change the name of the classes as ur teacher will find that u used his classes :) cheers.
Here are his classes.I tried and it worked.
Class1
import java.awt.Component;
import java.awt.Frame;
class ComponentUtilities
{
public static Frame getTopLevelParent(Component component)
{
Component c;
for(c = component; c.getParent() != null; c = c.getParent());
if(c instanceof Frame)
return (Frame)c;
else
return null;
}
ComponentUtilities()
{
}
}
class2
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class MessageWindow extends Dialog
{
protected boolean modalResult;
Button okButton;
protected MessageWindow(Frame frame, String title, String msg)
{
super(frame, title, true);
modalResult = false;
add("North", new Label(msg));
Panel mainPanel = new Panel();
okButton = new Button("Ok");
mainPanel.add(okButton);
add("Center", mainPanel);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event)
{
modalResult = true;
setVisible(false);
}
});
pack();
}
static boolean doModal(Applet aplet, String title, String msg)
{
System.out.println("=========");
Frame frame = ComponentUtilities.getTopLevelParent(aplet);
if(frame == null)
frame = new Frame("Empty");
MessageWindow tn = new MessageWindow(frame, title, msg);
java.awt.Point aploc = aplet.getLocation();
aplet.setEnabled(false);
tn.setLocation(200, 300);
tn.setVisible(true);
aplet.setEnabled(true);
return tn.modalResult;
}
}
and in ur class QueryApplet
in the actipn listener of ur button show MessageDialog as
check if text in nazwLab is null or empty ...show similary u can check all the conditon remove ur code from actionlistener.
Moreover checq the line of code in init ()
String bcVal = getParameter("BGCOLOR");
make sure to provide correct input else it will through exception
MessageWindow.doModal(this, "B\u0142\u0105d", "Nie podano nazwiska klienta");
nazwLab.requestFocus();
return;
Hope that will help .....else ciao tomorrow...time for me to go to bed else mamma will shout ;)
goodluck