Dialog in Applet

Hi,
I'am building an Applet.
I want to open dialog in the main window.
Main window is an applet window.
But, to build dialag I should pass as parameter Frame.
Main class is extends applet and not Frame.
Thanks,
Evgeny

Nottin too difficult here ...
public class NameApplet extends Applet
String name = OptionPane.showInputDialog("Please enter your name.");
}

Similar Messages

  • Hidden dialog renders applet unusable

    i have a problem with dialogs in my applet.
    if an applet dialog is open, and the user minimizes the browser or switches to another application, the dialog gets pemanently hidden (at least in firefox). there's no way to locate the applet again, and hence, no way for the applet to regain focus.
    clicking around on the applet generates a system beep but does not cause the dialog to reappear.
    one obvious approach is to eliminate dialogs. i need the dialogs, though, and want to ask the community if better alternatives exist.
    any ideas? does anyone else have this problem?
    thanks!

    i figured how to make the applet modal with both the Microsoft JVM and the SUN JVM. from reading posts elsewhere on the web, it seems like people have also had trouble with making dialogs modal with the Microsoft JVM. this solution also makes it possible for someone to switch applications while a modal dialog is open without causing the applet to be unusable. when the user switches back to the browser/applet, the blocking dialog is on top of all windows versus being hidden as it would normally.
    ==================
    BEGIN CODE
    ==================
    public NonblockingDialog (Frame parent, String title) {
              super(parent, title, true);
    addWindowListener(new WindowAdapter() {
                   public void windowDeactivated (WindowEvent we) {
                        requestFocus();
                        toFront();
    ==================
    END CODE
    ==================

  • How to center Dialog over Applet?

    A quick question.... When I create a Dialog in an Applet, I have to create a "dummy" frame to be the parent/owner of the Dialog. As a result, when I display the Dialog, it shows up in the upper-left corner of the screen. How do I use a Dialog in an Applet so that it displays centered over the Applet?
    Thanks,
    Nordman

    I have to create a "dummy" frame to be the
    parent/owner of the Dialog.No. you do not. You can use the browser frame.
    In the applet you can get it like this:
    Frame browserFrame;
    Component comp= this;
    while (! (comp instanceof Frame))
       comp = comp.getParent();
    browserFrame = (Frame)comp;you can also use setLocationOnScreen() to set the dialogs position. To set it relative to the applet or the browserFrame, you call getLocationOnScreen on those, and calculate whatever position you want.
    Ragnvald Barth
    Software engineer

  • Please help!! How to communicate between applet and pop up dialog box

    Hi friend,
    I have done a AWT pop up dialog box from Applet. In this pop up dialog box, I want get user name, and display on an Applet, anyone can tell me how to do? Thanks a lot!!!!
    Alva

    You need to create two methods in your applet, getName and setName as well as a name field.
    private name = "";
    public void setName(String n)
        name = n;
    public void getName()
        return name;
    }The various constructor methods for Dialog already take the owner of the Dialog (your applet) as a parameter, so in your applet's ActionEvent handler, all you have to do is call
        name = textName.getText().trim();
        owner.setName(name);Yes, it's that easy.

  • Java security dialog freezes Java & browser when loading signed applet

    Hi,
    I have a slightly unusual scenario: I have two signed applets. One is developed by me and another one by somebody else. Let's call them Applet A and Applet B.
    Here is what hapens:
    1)Applet A loads
    2)Security dialog for Applet A - "yes, trust this vendor"
    3)applet A loads applet B with the following code taken from this sample:
    http://www.java-tips.org/java-se-tips/java.applet/have-an-applet-launch-another-applet.html
    Class appletClass = Class.forName(appletToLoad);
    Applet realApplet = (Applet)appletClass.newInstance();
    realApplet.setStub(this);
    setLayout( new GridLayout(1,0));
    add(realApplet);
    realApplet.init();
    realApplet.start();
    4) Applet B loads
    5) Applet B security dialog shows up, but it is gray. From this point on, nothing resonds. The java console is gray, all browser windows are frozen, the dialog is gray and frozen. I can move it around, but it leaves trails.
    The only hint that I have is that the last security dialog is a modal dialog, but it seems like it's pushed twice, possibly causing a deadlock?
    This is what I see in the trace file:
    security: Certificate has been verified with Root CA certificates successfully
    security: No timestamping info available
    basic: Modality pushed
    basic: Modality pushed
    Usually a "Modality pushed" is followed by a "Modality Popped".
    Does anyone have any idea how I can go about resolving this problem? This is not an issue if I manually import the certificate for Applet B into the java cert. store.
    Thanks.

    Were you able to figure out the problem? I have the same issue and it is killing me. Please share with me anything you found.

  • Directory Tree in Applet

    Hi I am new to Applet development, and have decided to make a system that allows users to upload multiple Images at once with ease. Similar to Facebooks one, but made by me.
    I am trying to have a JTree on the left that displays all the drives/folders etc of the users system. I have used code I have used on applications but am getting
    java.lang.ExceptionInInitializerErrorSo guessing there is a different way I need to do it.
    Can anyone tell me how I can get the desired functionality please.
    AberProgrammer

    >
    So once I have digitally signed it, it will magically just start working (or at least not throw Security Exceptions)??>No. You will note that I added (and trusted) to my original reply. You can sign it, and provide it in a web page for the end user to download and use, but it is up to the end user to click 'OK' when it comes time to trust the applet. If the user refuses that trust dialog, the applet will be sandboxed.
    Here is [an example|http://pscode.org/test/docload/]. If the user trusts the code, they get a red document, otherwise the green document. It is mentioned in the SDNShare post [Defensive Loading of Trusted Applets|http://sdnshare.sun.com/view.jsp?id=2315].
    Note also that one single '?' denotes a question, while two or more denotes a dweeb.

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an image in my JDialog, but my code gives me a nullPointerException during the Runtime.. Here's the exact Runtime error:
    Exception in thread "main" java.lang.NullPointerException
            at applet.<init>(applet.java:16)
            at applet.main(applet.java:100)And here's my exact applet.java file:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        private ImagePanel panel;   
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String name)
            try
                buffered = ImageIO.read(new File(name));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if (buffered == null)
                g.drawString("No Image", 10, 40);
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
         MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }And I don't see any errors, but still.. Runtime error.. -.-' So a little bit of help would really be appretaiced!

    Okay I guess I spoke to soon.. :O Now I have no Runtime error but my JDialog is completly empty.. And my BlackTheme stopped working.. Not It's a blue theme instead..
    Here take a look at my applet.java:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        ImagePanel panel = new ImagePanel("background.gif");  
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String s)
            try
                buffered = ImageIO.read(new File(s));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if(buffered == null)
                System.out.println("No image to display.");
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
            MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }

  • Applet fails to render

    Developing an applet based on java sound demo. Signing, certs, client access all working great MOST of the time. Issue: sometimes, after clicking yes on the cert dialog, the applet comes up blank(grey- the bgcolor). No error is shown in the plugin console so I am left to think it may be an issue with request time-out, but just guessing as there is seemingly no way to debug. Sure would like a tip from the Duke.
    all help appreciated.
    Mike D.
    HormannAmerica, Inc.

    Enable a full trace and check that out.
    Put some System.out.prinln in your code to see where your code hangs, since
    it doesn't produce an exception it probably has some blocking code. (like
    reading from a socket that doesn't produce any data and isn't closed by the
    sender)
    Or you cought an exception without printing the stacktrace.
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0_03.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    Print out the full trace of the exception:
    try{...}catch(Exception e){e.printStackTrace();}

  • Applet won't repaint itself

    i have an applet that contains a jtexatrea 3 buttons and a jlabel.
    when i start it everuthing is just fine.
    however, my applet is supposed to open a file form the local filesystem (so it is signed) and after i click OK in the choose file dialog, my applet keeps the image of the dialog.
    what do i have to do in order to solve this ?
    p.s. and the same issue occurs when i minimiza the browswer and maximize it again. it just won't repaint.

    A potential solution occurred to me right after I posted, and I think it may be working. (Can't tell for sure until search engine cache's updated with this change.) Basically I expanded the .jar archive name:
    <script type='text/javascript'>
    <!--
    applet_fu.run(
      {'width':'850','height':'690'},
        'archive':'http://r0k.us/graphics/SIHwheel.jar',
        'code':'SIHwheel.class',
      '1.4.2',
      'Get Java for free at http://java.com/ '
    -->
    </script>Before the change, the archive line simply referenced 'SIHwheel.jar'.
    The one downside to this, assuming it works, is that I'll need two versions of the page. A local one on my hard drive for when I want to test before deploying, and the networked version with the full URL. That's a worthwhile trade-off, though.
    Edited by: RichF on Nov 27, 2010 10:39 AM
    PS: the link in first post still fails, but it seems to be accessing yesterday's version of the page (date on bottom). Also I note that the HTML for that Google-translated page and Bing's cache page contain:
    <base href=http://www.r0k.us/graphics/SIHwheel.html />That works well for accessing all the locally-referenced images on the page, but for some reason fails to find the .jar file without a complete URL. The [url http://r0k.us/graphics/applet-fu.js]applet-fu.js script does not appearing to be adorning the archive line in any way.

  • Regression in 7u55+ prompts for authentication dialogs (JDK-8046211)

    I'm tracking issue JDK-8046211 and noticed today it was resolved as "won't
    fix" without any comment
    Our situation: We have a Java applet consisting of 4 jar files and a JNLP
    file. These files are served over HTTPS from a public webserver (no
    authentication required). The applet contains an up-to-date manifest with
    all the entries required since the new Java security baseline. The
    applet/JNLP file is accessed from a web application using Javascript
    (deployJava.js). All interaction with the applet is through Javascript.
    The web application itself runs on a different server and is protected
    using client certificates (2-way SSL) and basic authentication.
    Now until Java 7u55 everything worked fine. When loading the applet only
    one popup was displayed asking the user to trust the applet (which is
    properly signed) and that was all.
    However since 7u55 (also 7u60) things have changed: the applet loads fine
    but as soon as we call a method on the applet (though LiveConnect) the Java
    VM displays a popup asking the user to select a client certificate and
    thereafter asks the user to authenticate using BasicAuth.
    Important note: the user doesn't actually has to select a valid certificate
    or enter any credentials. If the user cancels any of the dialogs the applet
    continues to function properly. Logging shows the applet is using the same
    cookie as the browser so authentication against the server isn't actually
    taking place. Basically the Java VM is prompting for authentication dialogs
    for no good reason because the user is already authenticated with a browser
    cookie.
    Prior to 7u55 we didn't experience this issue (we have users with 7u40,
    7u45 and 7u51). Altogether it appears we encountered JDK-8046211, which has
    the characteristics of a regression issue.
    I'm curious if more people have experienced these issues (I know applets aren't the hottest tech out there....)

    Yes the problem is due to an extra HTTP call fired from the Java plugin (only under IE, no issues in Firefox) to the page that embeds the applet. So it's different from JDK-8046211 although the result is the same.
    We eventually implemented a workaround: we intercept the extra HTTP request in our frontend proxy server (Apache) and always return 200 OK prior to doing BasicAuth. Here's our mod_rewrite config implementing this workaround:
    RewriteEngine On
    RewriteLog /var/log/apache2/java_issue_rewrite.log
    RewriteLogLevel 0
    RewriteCond %{REQUEST_METHOD} =GET
    RewriteCond %{HTTP_USER_AGENT} Java/1.[7-8]
    RewriteRule ^/path/to/page/embedding/java/applet /dummy.html [R=200,L]

  • Print from applet, signed jar

    Hi all
    Have a signed applet that runs under IE 6, java 1.5. The applet is basically used for printing purpose.
    My problem is that the applet shows a dialog box "Applet would like to print. Do you want to proceed?"
    How can I get rid of the dialog box?
    I don't want to change the Java file.
    Thanks in advance

    An Applet runs in a sandbox which without proper authentication, will not allow any actions outside the sandbox, i.e. on the local filesystem.
    You cannot print from an unsigned applet.
    The signing process is very simple using Jarsigner and the Java Plugin.
    You can generate your own certificates too, no need to purchase one.

  • Catch pop-up dialog

    Need sample code to perform pop-up dialog in applet catch code block to output e.getMessage(). println() appears to go nowhere. Thanks.

    Here's a simple example of how to catch popup triggers in an applet.
    ---------------- PopUp.java -------------------------
    import java.awt.event.*;
    public class PopUp extends java.applet.Applet implements MouseListener {
    public void init() {
    addMouseListener(this);
    public void mousePressed(MouseEvent e){
    if (e.isPopupTrigger()) {
    System.out.println("Caught Popup event");
    public void mouseClicked(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseReleased(MouseEvent e){}
    --------------- End of PopUp.java --------------------
    ------------------- PopUp.html ----------------------
    <applet code="PopUp.class" width="200" height="60">
    </applet>
    ------------------- End of PopUp.html ---------------
    % javac PopUp.java
    % appletviewer PopUp.html
    The applet window that shows up will catch popup events. Is this what you're looking for?

  • Need help on sharing a jsp page between clients?

    Hi,
    Let me explain this:
    In my jsp application I have two jsp pages that work as a find dialog like applet find dialog.One of those shows the columns from rowset(which user can enter the criteria ) and the other gets the values from first one, makes the sql query and execute the query against the rowset and retrieve the data. There is no pure servlet, both are jsp pages.
    This application is deployed on AS9i-oc4j.
    Problem is : When this find dialog is working for a client. The other client could not load this find dialog until the work for the first one be done. I mean only one client could load and fire the sql statement via this jsp pages(find dialog) at the same time. Which is not acceptable in web applications. Seems only one instance of these pages created by oc4j . if I am right on this then
    Question is : Why oc4j doesn’t create the number of instances based on the number of clients that call these pages? Did I miss something. Or any property in Application module need to be set?
    I would appreciate to share me your idea on this.
    Thanks.

    In my primary mind maybe the bottleneck is where the execution of rowset happens. Since that portion of code takes time to retrieve data for business components. If this is the case then Is this problem goes away if I define a thread for this portion of code?
    Thanks in advance for any idea.

  • "New" has stopped working

    In JDev 3.1, "New" (class) has stopped working. I've tried class, frame, applet and not work now. I've restarted Jdev and it still happens.
    The dialog with applet, frame, class, etc does come up, but after I select one and click OK, nothing happens.
    How do I turn it on?
    P.S. The dialog needs an "interface" creation "wizard".

    Found it. Didnt have "root source directories" in project properties defined.

  • Plug-in slow on heavy date

    Hi there,
    I'm running an applet, which opens a swing dialog, showing a table with only a few hundred rows of data. After closing the dialog, the applet is damn slow. I mean, really slow. The dialog close() method does contain a dispose() and System.gc(). What else can be done to speed up things (besides not showing so many rows) ? Any hints?
    regards
    Heiner

    ahm, I'm sorry. I think you didn't quite understand my problem (or I wasn't describing it good enough). Its not a problem of loading. It's a runtime problem. I have an applet running, which works fine. Somewhere, during runtime, I open a dialog with a few hundred rows. The user hits 'ignore' or 'accept' and the dialog is closed. In the close method, I call dispose() and System.gc() to clean up things. However, afterwards the applet becomes very damn slow. I assume this is because it still deals with this huge amount of data, somewhere in the background. Now, my question is, how can I clean up after me, to convince the system for no longer caring about the data.
    greetings
    Heiner

Maybe you are looking for

  • Messages Stuck in Mail App Outbox

    I have an iphone 4S with IOS 6.1.3.  I use the Gmail app with no issues to send and receive messages.  However, when I attempt to send mail attachments directly from the phone's voice memos or camera roll functions, the messages get stuck in the Mail

  • Rebate: Differ "Scale Base Value" between "Statistics" and "Billing Doc"

    Dear SD Expert,             After I go with Transaction Code :"VOB3" (run report RV15B002), I found that "Scale Base Value" have different value between "Statistics" and "Billing Doc". And the correct value is "Billing Doc". However, the value which

  • Using pdf templates

    My book publisher provides pdf templates to use to create book covers. These pdf templates have exact sizes that need to be followed exactly. I realize that Adobe Acrobat XI is not an editing program so my question is how do I fill out the fields in

  • ORA-06512 at stringline string

    Has anyone ever dealt with this? if so, what is it? how do I fix it? also... Cause: Backtrace message as the stack is unwound by unhandled exceptions What is a backtrace?

  • Downloading an installing Creative Cloud on a back up mac

    I am a Creative Cloud member and have installed CS6 and more on my new iMac at the office – where everything works fine. Now I want this on my MacBook Pro, but I can't find where to download on my Adobe-ID account... I really need this to work at hom