applet dialog not showing
Hi,
I have a problem with dialog not showing. The code is as follows:
In applet:
new TextDialog(100, 100,"This is a test");
TextDialog class:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
class TextDialogextends Dialog
implements ActionListener, TextListener, KeyListener
{
private TextArea ta;
privateboolean changed;
private Font font =new Font("Monospaced",Font.PLAIN,12);
public TextDialog(int w,int h, String t){
super(new Frame(),"TEST",true);
this.setLayout(new BorderLayout());
ta.setFont(font);
ta =new TextArea(null,5,50);
this.add("Center", ta);
Panel panel =new Panel();
Button cancel =new Button("Cancel");
cancel.addActionListener(this);
panel.add(cancel);
Button ok =new Button("Ok");
ok.addActionListener(this);
panel.add(ok);
this.add("South", panel);
ta.addTextListener(this);
this.add(panel);
this.pack();
this.setVisible(true);
ta.append("Showing?");
fr.setVisible(true);
}
}
And some more stuff not necessary to show here I suppose.
Can anybody tell me what the problem is?
Best regards,
Mikkel
[2834 byte] By [
mihan99a] at [2007-10-3 10:32:28]

OK, Here is the entire code of the TextDialog class:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
class TextDialog extends Dialog
implements ActionListener, TextListener, KeyListener
{
private TextArea ta;
private boolean changed;
private Font font = new Font("Monospaced",Font.PLAIN,12);
public TextDialog(int w, int h, String t) {
super(new Frame(), "TEST", true);
this.setLayout(new BorderLayout());
ta.setFont(font);
ta = new TextArea(null,5,50);
this.add("Center", ta);
Panel panel = new Panel();
Button cancel = new Button("Cancel");
cancel.addActionListener(this);
panel.add(cancel);
Button ok = new Button("Ok");
ok.addActionListener(this);
panel.add(ok);
this.add("South", panel);
ta.addTextListener(this);
this.add(panel);
this.pack();
this.setVisible(true);
ta.append("Showing?");
}
public void actionPerformed(ActionEvent actionevent) {
if (actionevent.getActionCommand().equals("Cancel")) {
this.dispose();
}
else if (actionevent.getActionCommand().equals("Ok"))
this.dispose();
}
public void textValueChanged(TextEvent e) {
// Update the signtext
changed=true;
}
public void keyReleased(KeyEvent keyevent) {
/* empty */
}
public void keyPressed(KeyEvent keyevent) {
if (keyevent.getKeyCode() == 10)
this.dispose();
}
public void keyTyped(KeyEvent keyevent) {
/* empty */
}
}
Hope it helps...
Mikkel