Open a JDialog from an JApplet

Hello,
I have an applet and I want to open a separate window. The problem is that I want this window to be modal, and therefore I have to use a JDialog, but a JDialog needs an owner that can only be a JFrame or a JDialog, so I cannot use the JApplet as an owner. I tried to set the owner to null, but then if the user changes the focus to another window in his/her OS, and then returns to the browser, the JDialog does not reappear, so the applet is stuck!
Does anybody have an idea how I can solve this problem?
Thanks very much.

Yes, cuz all applets have a frame....
Frame f =
(Frame)SwingUtilities.getAncestorOfClass(Frame.class,
this);Thank you very much. I will try this solution.

Similar Messages

  • Problem displaying JDialog from a JApplet

    When I try to display a JDialog (of a JFrame) from a JApplet, the dialog is displayed but it never receives any paint events, so the form seems empty.
    Basically, this is what happens:
    A JPanel is added to the content pane of a JApplet.
    When that panel receives a mouse action event, a new window is created like this:
    TestWindow tw = new TestWindow();
    tw.setVisible();That's it. When the window is started from a method in the applet itself, however (init() for example) the window does display correctly.
    Can anyone tell me what might be going wrong?

    /*  <applet code="AppletDialog" width="300" height="180"></applet>
    *  use: >appletviewer AppletDialog.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AppletDialog extends JApplet
        JDialog dialog;
        public void init()
            initDialog();
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(getNorthPanel(), "North");
            getContentPane().add(getSouthPanel(), "South");
        private void initDialog()
            JLabel label = new JLabel("dialog contents", JLabel.CENTER);
            dialog = new JDialog(new Frame(), false);
            dialog.getContentPane().add(label);
            dialog.setSize(200,100);
            dialog.setLocation(540,200);
        private JPanel getNorthPanel()
            JButton launch = new JButton("show dialog");
            launch.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    dialog.setTitle("from button");
                    dialog.setVisible(true);
            JPanel panel = new JPanel();
            panel.add(launch);
            return panel;
        private JPanel getSouthPanel()
            JPanel panel = new JPanel(new BorderLayout());
            panel.setBackground(Color.pink);
            panel.add(new JLabel("click here for dialog", JLabel.CENTER));
            Dimension d = panel.getPreferredSize();
            d.height = 45;
            panel.setPreferredSize(d);
            panel.addMouseListener(new MouseAdapter()
                public void mousePressed(MouseEvent e)
                    dialog.setTitle("from mouse");
                    dialog.setVisible(true);
            return panel;
        public static void main(String[] args)
            JApplet applet = new AppletDialog();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(applet);
            f.setSize(300,180);
            f.setLocation(200,200);
            applet.init();
            f.setVisible(true);
    }

  • How to open web pages from japplet??

    Hi
    Does anybody know how to open web pages from java japplet??
    Any help is apreciated!
    zick

    the getAppletContext() method of the Applet class will get you an AppletContext, with which you can call the ShowDocument(URL url) or ShowDocument(URL url, String target) method...
    check it out at http://java.sun.com/j2se/1.4/docs/api/java/applet/AppletContext.html
    have a good one :)
    Jay

  • Jdialog from JDialog

    Hello guys,
    I apologize for those that read many posts. I posted a question on the Swing Forum and haven't gotten much of a respond. My generally feeling is that my question is too basic for anyone to take the time to answer.
    How does one open a JDialog from a JDialog?
    I created and added the JButton the parent JDialog.
    When I click on the "show" button I want it to launch another JDialog with a JScrollPane.
    Thanks

    hi,
    well you could just use the setVisible(true) method in the actionListener for the button. Suppose there are 2 JDialogs jd1 and jd2. jd1 has a button, using the buttons actionListener, actionPerformed method, you could write something like:
    jd2 obj = new jd2();
    jd2.setVisible(true);this will pop open the second dialog. so just make 2 classes, one for each dialog and use something like the above to show the second one from the first one.

  • Open new browser window from a JApplet

    Hi,
    I want to open a new browser window from a JApplet.My first thought was to use the Live Connect technology but it worked only with simple applets not with JApplets.Then i tried it by getting the Applet context (getAppletContext() method) but it still didn't work with JApplet...(it worked with Applet).I believe it has something to do with the applet security but i haven't yet figured it out.
    For example when i call the getAppletContext() method from a JApplet i get an java.security.AccessControlException ... .Thanks

    I must correct myself now :).
    The getAppletContext() method does work with JApplets too.Still , i have problems with the Live connection alternative.It seems that it by importing the netscape.javascript package i get the security eror that i mention above...

  • Executing a JDialog  from another JDialog

    Hi,
    Is there a way to popup a JDialog from another JDialog and then close the first one.
    I have a button in a Jdialog that I want to open another Jdialog when the user click on it.
    The only way I could think of is to write a code that start another JDialog and close the first one.
    ----kirk

    In the Action performed function you can dispose or hide the first dialog and can bring up the second dialog.
    public void action performed(ActionEvent e)
    //button event
    this.dispose();
    SecondDialog dialog = new SecondDialog();
    dialog.show();
    }

  • Open and read from text file into a text box for Windows Store

    I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
    Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
    Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
    Thanks
    Wendel

    This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Storage;
    using System.IO;
    namespace TextFileDemo
    public class TextFileHelper
    async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
    byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
    try
    using (var s = await file.OpenStreamForWriteAsync())
    s.Write(fileBytes, 0, fileBytes.Length);
    return true;
    catch
    return false;
    async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
    StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    show how to use it as below
    async private void Button_Click(object sender, RoutedEventArgs e)
    string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
    Debug.WriteLine(txt);
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

  • Migrate all Open Sales Orders From Legacy System (SAP) To SAP System using

    Hi Experts,
                 I've to Migrate all Open Sales Orders From Legacy System (SAP) To SAP System using Business Objects with a new SALES ORDER DOCUMENT NUMBER referencing the older one.
               I'll get all the required data with field in an excel file.
                 Does any standard transaction exist for it ? Or how to go ahead with it ?
    Thanks and regards,
    Jyoti Shankar

    Hi
    If you are checking for CREATE option then Sales Doc Type
    For more Info goto SWO1 transaction -> BUS2032 --> DIsplay --> Execute --> There SELECT the method which you want to perform... There you can fine the MANDATORY parameters also....
    Or in DISPLAY mode PLACE Cursor on the Required Method and CLick the PARAMETERS button on toolbar...
    That will show the MANDATORY parameters...
    Reward if helpful....
    Message was edited by:
            Enter the Dragon

  • Uploading open sales orders from sap

    hi all,
    i need to upload open sales orders from legacy to sap. pls advice what steps need to be followed for the same.
    1) how we will we download open sales order from legacy and where..... is it to some flat file or some other option is  there . pls tell some options.
    2) how we will uload the sales ordes into sap . thru lsmw or is there some other option ?
    3)  there will be more number of fields in sap than in legacy. i think we need to manully create an excel file and add more fields manually in excel file so that the compulsonry feilds as per sap are present in sap ?
    4) how will availability check happen  in sap after sales order are t/f from legacy ?
    rgds
    pamela

    hi pamela,
    1.a. you need to down load in EXCEL in legact format and convert the same in LSMW format and upload it
    2.a. LSMW - Functionally, BDC, BAPI - Technically. to my knowledge LSMW is better option.
    3.a. first you download to EXCEL file from LEGACY, then align the same to SAP format you can add those fields that are mandatory as per your requriment.
    4.a.You are uploading sales orders in SAP which are showing OPEN status from LEGACY before you uploading the sales orders MM consultant would have uploaded its stock through 561 - dont worry on that, even though if stock is not uploaded also not an issue it will confirm at the later date.
    5.a. we have used LSMW process for our PREVIOUS ASSIGNMENT, before that we tested BAPI for it some how it was not capturing some fields.
    hope all your queries are solved
    balajia

  • Pages downloaded, but I still can't open iCloud pages from iPad. Says that I need a new version of Pages on my Mac

    For my Mac Pro, after I downloaded the new Mavericks OS, I downloaded the new pages. However, I still can't open iCloud pages from iPad. Says that I need a new version of Pages on my Mac.
    Please help.

    It appears that you are launching the old version, probably using an icon in your Dock. That icon is an alias & is not updated. You will need to go to your Applications folder & find the new Pages 5 icon & double-click it. Once it is launched, you can right-click on the icon & choose Options > keep in Dock from the contextual menu.

  • Pages 2.0.2 doesn't open Pages documents from ipad

    Pages 2.0.2 doesn't open Pages documents from ipad 2. Document succesfully transferred as Pages document to computer, but Pages 2.0,2 wouldn;t open it. Version too old?

    Pages 2 is iWork '06, two versions behind what the iOS Pages creates. You need to use Pages '09 which you can purchase from the Mac App Store as a stand-alone application or a retail box of the iWork '09 suite.

  • Open all pages from last session

    Occasionally, safari will die. When I restart safari:
    is there a function to open all pages from last session?
    does firefox have this function? I thought I saw it within firefox, but I can't find it now. If this function is in firefox, where is it?

    In Safari... History > Open all pages from last session
    Firefox should do it automatically.
    Dave

  • Open Pages documents from an older version

    I need to open Pages documents from an older version of Pages that I saved to an external drive from a computer that I no longer have access to.  My current operating system is 10.7.5 and I can't upgrade it right now.  I see that Pages 5.0 requires 10.10 or higher and I can't find older versions to download and from what I've read, it doesn't sound like I'd be able to open the old documents with the new version anyway.  I really need these documents. What can I do?

    I found it helpful to convert all my old Pages '08 files to .doc files.  They can be opened by the new version of Pages.
    Since the new version of Pages is no longer back compatible, and so not good for anything you want to keep for a long time, you might consider using an open source word processing application like Libra Office.  That's what I had to do.  After seven years of being a happy Pages user - archiving thousands of files in Pages -Apple has abandoned us.  I no longer think it is wise to use the new Pages and then five years down the road (or sooner) not to be able to open them in a newer version.
    If you would like a quick way to convert your Pages '08 files to .doc, let me know.

  • I am trying to open CR2 files from a Cannon EOS 1DX camera in Photoshop CS6 and I have already updated the Camera Raw Plug in but Photoshop is still giving me the cannot open files dialog box? Help?

    I am trying to open CR2 files from a Cannon EOS 1DX camera in Photoshop CS6 and I have already updated the Camera Raw Plug in but Photoshop is still giving me the cannot open files dialog box? Help?

    Canon 1DX support was added to ACR in version 6.7, 7.1.  An updated CS6 should be at level ACR 8.6.  If your ACR is not at level 8.6 try using CS6 menu Help>Updates.  If that does not install ACR 8.6 try downloading the ACR and DNG 8.6 converter and see if ACR 8.6 will install into your CS6.
    Adobe - Adobe Camera Raw and DNG Converter : For Windows
    Adobe - Adobe Camera Raw and DNG Converter : For Macintosh

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

Maybe you are looking for

  • Laserjet Pro 200 Color MFP M276nw installation error

    On a laptop running Windows 8 (I have tried several times, including rebooting): Whether running LJ-Pro-200-color-MFP-M276-driver-installer-14057.exe or LJ-Pro-200-color-MFP-M276-full-solution-14057.exe I get the same error: A problem occurred while

  • Missing functionality if storing TDSM from LabVIEW

    In DIAdem File Browser window is selected a file from DIAdem 11.0 Examples directory. File FFT_Expl_1 has icon with „tree pictogram" and „tree pictogram" can be expanded to see content of file (Time, Oscillation), bellow of File Browser is displayed

  • Documents types used in brs

    hi,   can more than one document types be defined while configuration of manual as well as in electronics bank statement?here we are using more than one documents types as we have more than one bank account in different banks while posting transactio

  • Session stats

    Hi, I'm using below query to get the long running session statistics. based on the output i have to set the alert, once the seconds in wait reached the threshold value... the alert will be in red. can you please guide me, how to set the thershold val

  • How to integrate two Siebel Applications into single app UI

    Dear All, Currently we have a Siebel application which is running with various Siebel modules. Like for example in one single application object manager we are having various screens and views related to various modules like UCM, Loyalty, Marketing e