Unable to open JDialog from swing application when run from Applet

I have created a swing application, which runs fine when I run from desktop. The same application is now run from Applet.
class abc extends JApplet
 new Main()

Main class extends JFrame, it has JDialog opens for Login.
Now my problem is When I run Applet login dialog does not open up. I dont see any error in Applet console.

Any Thoughts?
Who is Participating?
Pramod KumarConnect With a Mentor Commented:
Try this:

import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;

public class Login extends JApplet implements ActionListener
    JButton b;

  private Frame findParentFrame(){
    Container c = this;
    while(c != null){
      if (c instanceof Frame)
        return (Frame)c;

      c = c.getParent();
    return (Frame)null;

  public void init(){
    setLayout(new FlowLayout());
    b = new JButton("push me");

  public void actionPerformed(ActionEvent e){
    Frame f = findParentFrame();
    if(f != null){
      JDialog d = new JDialog(f, "modalDialog", true);
      d.setLayout(new FlowLayout());
      d.add(new Label("hello"));

Open in new window

That may be due to some limitationm with the browser to open new windows - like pop-up blocking or something like that

Try in another browser.
harishalwalaAuthor Commented:
OK it works
harishalwalaAuthor Commented:
I got the way for finding solution, though this is not the actual solution I am looking for
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.