About applets

hi,
can someone tell me if i can use addWindowListener method to close an applet.if yes,how?

I don't want to say no, but I think the answer's no. Here's why:
Applet is derived from java.awt.Panel, as such it does not have an addWindowListener method. The addWindowListener method starts with java.awt.Window, which is one level higher in the awt class hierarchy.
Does that mean that you can't get the handle to the native window of the applet browser? I don't know for sure, but that could open a nasty security breach, and these Sun guys are pretty tight on that stuff. I understand why it would be handy to have a windowListener for the browser, but you'll have to rely on the start and stop methods of Applet which the browser will call automatically, when it changes your applet's visiblity.
If you do find a way, I'd be floored, and I have been doing this stuff for years! Be sure to post it here.
Best Wishes,
John

Similar Messages

  • About applets and secure connection

    Hello. I've read some threads but I can't understand a thing about applets and SSL.
    I've a signed applet. This applets is embedded with applet tag in a jsp page.
    The applet works as a file uploader.
    With signing, the applet can access to the user file system without problem, open a connection with the server and upload files.
    Now, If I want to use HttpsUrlConnection instead of the standard http connection, what certificate does the applet use for handshake? Does the applet automatically use the same certificate used for signing?
    Thank you

    Hello. I've read some threads but I can't understand a thing about applets and SSL.
    I've a signed applet. This applets is embedded with applet tag in a jsp page.
    The applet works as a file uploader.
    With signing, the applet can access to the user file system without problem, open a connection with the server and upload files.
    Now, If I want to use HttpsUrlConnection instead of the standard http connection, what certificate does the applet use for handshake? Does the applet automatically use the same certificate used for signing?
    Thank you

  • Confusion about applet

    sir
    i have confusion about applet that if an applet compile successfully but on running it shows a exception message about "main"that no such method exist.help me out please

    The full text of the error message would make it easier for us to see what is wrong BUT it sounds like you are trying to run the Applet as an applicaiton from the comand line rather than through an HTML tag in an HTML page loaded into your browser!
    Though you can make Applets run as applications it not normal to do so.

  • About applet lock

    Hi,
    I have written the code for an applet file. I'd like to do something or put a password on the file that the code wouldn't be accessable, I mean that if I send the file to somebody and he wants to see the HTML file, he can't see the codes (confidential) .
    Thanks
    Mohammadreza

    Hi,
    I have written the code for an applet file. I'd like
    to do something or put a password on the file that
    the code wouldn't be accessable, I mean that if I
    send the file to somebody and he wants to see the
    HTML file, he can't see the codes (confidential) .
    Thanks
    MohammadrezaYou mean the Applet code? Because forget about hiding the html. The source code for the Applet is only visible if you make it so. The class, however, is downloaded to the users machine and can be deciphered by those who really want to.
    Why is this so important to you?
    ~Bill

  • Security permissions question about Applets

    Hello all.
    I'm wanting to make an address book on my server, so I need to have it write to a file. I've read a bunch about it, and still can't figure it out.
    I'm not exactly sure what the java home is supposed to be. I created a java.policy file in /usr/lib/j2sdk1.5-sun (I'm on Linux), but I think it might belong in /usr/lib/j2sdk1.5-sun/jre or /usr/lib/j2sdk1.5-sun/jre/lib/security
    I'm also not exactly what the java.policy file is supposed to contain. Currently, it is:
    grant codeBase "file:/home/scott/public_html/address_book/old/*" {
            permission java.io.FilePermission "/home/scott/public_html/address_book/old/Test.txt", "write";
    };Anyone want to help?
    Scott Howard

    I'm wanting to make an address book on my server, so I need to have it write to a file.Well, applets run on the client - the browser which downloaded the class files - and therefore cannot access files on the server without some type of networking.
    Caveat - the client and server are the same physical machine.
    Solution - have your applet communicate back to the server it originates from. No policy twiddling is needed, as this is an automatic permission.

  • Question about Applet Securities / Permissions

    Hi,
    I'm about to begin work on a program that will utilize GData API to communicate with Google Calendars. I was wondering if this is going to be allowed in an applet, or if I would have to create it as a Java Application.
    I was looking at: http://java.sun.com/docs/books/tutorial/deployment/applet/security.html
    where it says "It cannot make network connections except to the host that it came from."
    I was wondering if that means I wouldn't be able to use to GData API to retrieve/create events in a Google Calendar.
    Thank you,
    Christopher

    Welcome to the Sun forums.
    elwell.christopher wrote:
    I was wondering if that means I wouldn't be able to use to GData API to retrieve/create events in a Google Calendar.Cool. Be sure to report the results of your experiment to test that. I'm sure others will be interested. And of course, feel free to drop back by if you have a question.

  • Doubts about applet triggering

    Hello guys,
    I was wondering, when I have my applet assigned to be triggered by a EVENT_UNFORMATTED_SMS_PP_ENV or even a EVENT_FORMATTED_SMS_PP_ENV, I mean, the applet being triggered by a SMS-PP message, what happens when I send two consecutive messages, i.e., when I send the second message and the applet is still processing the first one, what happens to the second message? is it lost by the ME or it is kept in some sort of buffer and re-sent to the applet when the applet finishes the process?
    As there are no threads on Java Card so both messages can't be processed at the same time...
    Thank you,
    Helri

    This is too broad a question.
    Toad can fire random sql.
    sql*plus can fire random sql.
    Why would Toad be the problem?
    You would need to gather statspack data to demonstrate this.
    Sybrand,
    Agreed on it and its a relevant point.But I guess he is not worried about the db performance.Anyways lets see what OP says.
    Inner join and left join will always use CBO (Cost Based Optimizer) instead of RBO.
    I am not sure that I have read that anywhere. They came into Oracle in 9i where optimizer mode was choose as the default one. Just by the syntax, oracle would push them to use CBO as the default one,I am not sure about this. Even if we are having + symbol and have the stats,Oracle wold go for CBO right?Can you please point me to some where in the docs where it is mentioned that using this keywords,Oracle would use only CBO?
    Aman....

  • Magic Number - Not about applets...

    This is a pretty silly question, but here goes.
    I am using a code checker to verify the style of the code I am writing and I am getting a number of warnings that 'n' is a magic number. I realize why Java uses magic numbers for Applets and such.
    I guess my question has to do with good programming practice. Is my cheker essentially saying that this hard-coded number should be preferrably set-up as a constant number somewhere in my system?
    I'd appreciate your thoughts.

    Yes, I guess so.
    Of course I don't know what code checker you're using, but in general a magic number in this context means that you're using an unexplained number.
    For instance, if you're using a for-loop that loops 20 times, and you're putting '20' in the loop itself (like: for (int j = 0; j < 20; j++) { ... }), it's a magic number. There's is no explanation offered why it's 20, so it's 'magic'.
    A better way to do this would be to define a static final int NUMBER_OF_LOOPS = 20 at some point in your code, preferrably with a short explanation about what it is and why it's 20 (and not 30) and then use that in your code.
    All numbers except 0 and 1 are considered 'magical' when unexplained.

  • Learning about applets

    Some help with the following problem would be most welcome. I would like to put some Duke stars up, but for some reason I do not have any.
    I am following the tutorials in Liang Introduction to Java Programming, Seventh Edition, and have just started on chapter 17, Applets and Multimedia. Although I have copied the first example as given in the book, it does not work. The browser gives me the message "Error. Click for Details." Clicking yields another error message: "The application failed to run. Click 'details' for more information." This time clicking the button, [details], opens a window containing the following:
    Java Plug-in 1.6.0_17
    Using JRE version 1.6.0_17-b04-248-10M3025 Java HotSpot(TM) Client VM
    User home directory = /Users/benjamin
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    p:   reload proxy configuration
    q:   hide console
    r:   reload policy configuration
    s:   dump system and deployment properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    ---------------------------------------------------- This is not helpful. I do not know what to do with this.
    The code that does not run is copied from the book (the package name is added by NetBeans), as follows:
    package learningapplets;
    import javax.swing.*;
    public class WelcomeApplet extends JApplet {
        public WelcomeApplet() {
        @Override
        public void init() {
            add(new JLabel("Welcome to Java", JLabel.CENTER));
    }The html page is:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Welcome Java Applet</title>
      </head>
      <body>
          <applet code = "WelcomeApplet.class"
              width = 350
              height = 200 >
          </applet>
      </body>
    </html>I am working on a MacBook Pro Notebook, and using NetBeans IDE, and fetching the html file with Firefox.
    file:///Users/benjamin/NetBeansProjects/LearningApplets/build/classes/learningapplets/WelcomeApplet.html
    The class file is in the same directory.
    I have tried cleaning and recompiling. Java is enabled on this browser. I have tried making xhtml markup, with no change in the outcome. I have tried Safari and Opera with the same results.
    I have tried replacing the <applet> tags with <object> tags, but this is worse; the browsers do not see anything at all.
    Edited by: Equitus on Feb 25, 2010 7:21 PM
    Edited by: Equitus on Feb 25, 2010 7:39 PM

    Equitus wrote:
    ..I had already tried using the valid markup, as follows: I'm glad you know about validation. It is a pity that ..
    ..This did not help, even though it is the markup used by the author from his site:
    http://www.cs.armstrong.edu/liang/intro7e/book/WelcomeApplet.html
    ..this author apparently has no clue. [http://validator.w3.org/check?uri=http%3A%2F%2Fwww.cs.armstrong.edu%2Fliang%2Fintro7e%2Fbook%2FWelcomeApplet.html&charset=(detect+automatically)&doctype=Inline&group=0].
    The author of that mess was apparently using a class that is not in a package. (My UA was able to guess what the author meant, and load that applet despite that rubbish pretending to be HTML).
    Also, adding the package name to the code property did not help.
    code="learningapplets.WelcomeApplet.class"
    I am not just making random guesses when I give you advice on applets. I have considerable experience with developing & deploying applets.
    And removing the .class made the situation worse. The browser did not see anything. There was not even an error message if .class was omitted.Did you try moving the packaged applet class to a subdirectory as I suggested?
    Also, you seemed to make a comment that implied you thought that if "Netbeans did it, then it must be right".
    Give up those fallacies right now.
    Netbeans is a powerful tool, but in the hands of someone that does not understand the underlying principles, it can make life a lot more complicated.

  • Something about applet and database?

    applet cant write and read from outer files.
    but can it read from database?if i don't modify my security policies.

    zhangv,
    We hava a web application with an applet in it that communicates with the server over HTTP. So, you need not worry about security. We use a multi-tiered environment. That is, the middle layer uses an application server (Sybase EAServer) and the backend layer is our database (Sybase ASE 12.5). Our application server fetches the data from the database and streams XML to the applet via a servlet. You can find a wonderful example for how this works in an article on Java world, entitled:
    Title: "A J2EE presentation pattern: Applets with servlets and XML"
    Subtitle: "Enhance your Web interfaces with powerful XML-configured applet components"
    http://www.javaworld.com/javaworld/jw-05-2002/jw-0524-j2ee.html
    Hope this helps
    TJJ

  • General question about Applets!

    Hi,
    I have a Win program I need to upgrade as a Web one.
    So, I'm not sure whether I should use an applet whetther do it with JSPs...
    I've used Java applets 4 years ago and I met some printings, (very)long downloading, security, ...problems.
    Obviously, the graphic result would be much better for me with an applet but could you please tell me if Java applets for Java 1.4.1 is more reliable that it used to be. Otherwise, I would finally choose JSP technology :-)
    Thx in advance,
    -G-

    the graphic result will probably not be better with applets at all. They exist to make it far easier to port java programs to the net, but they are pretty horrible to use as a result (as you have experienced). Problem is, users don't care about what makes it tick, they just see them as slow and generally rubbish. I would use JSPs or servlets, which are a far better use of Java's power. However, you will need to do more work. They can both call out to external classes and beans, so you can reuse that way, but obviously you will need to have a think about how to restructure the I/O. You just have to look at skills demands to see whats good and whats not... just about every java job now asks for J2EE (servlet, JSP and other stuff) skills, but when was the last time you saw a job ask for applet skills?!

  • About Applet displaying in different browsers

    Hi,
    When I am running my applet application in mozilla and IE browsers, its running properly. But In some versions of IE its not working properly that is I have a JTable where I am using the filter option from JDK1.6, in this table i will get some request data through server, but when I am running the applet in IE6.0, its not working with properly. Any body come across with this type of issue in past give some suggestion or solution.
    Regards,

    Are you sure IE6 is using Sun's plugin 6?
    If I'm right, IE is using M$'s JRE plugin by default, leading to crappy and unpredicable behavior.

  • About applet ,jsp ,!!!who can tell me  ????

    how can i pass data from applet to jsp ??????
    i have an applet , and i can have data in this applet
    i want to do like this :when i press a button in the applet,it is to show a new browser(jsp) ,and the data got form the applet
    will be sent to the jsp ( JspDataTest.jsp ).
    applet code like this :(i use it to send data to JspDataTest.jsp)
              urlInfo = new URL("http://10.33.9.82:8080/Project/JspDataTest.jsp");
              /**show jspDataTest.jsp*/                    
              getAppletContext().showDocument(urlInfo);
              /**open a connection*/
              HttpURLConnection connection = (HttpURLConnection)
                                  urlInfo.openConnection();                                                                 
              connection.setRequestMethod("POST");
              connection.setRequestProperty("Content-type", "application/octet-stream");
              connection.setDoOutput(true);
              connection.setDoInput(true);
              Vector data = new Vector() ;
              data.add("1");
              data.add("2");
              data.add("3") ;
              ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream());
              out.writeObject(data) ;
              out.flush() ;
              out.close();
    JspDataTest.jsp ,code like this : (i use it to receive data form applet )
    <%
    try{
              //get data
              ObjectInputStream in=new ObjectInputStream(request.getInputStream());
              Vector vv = (Vector)in.readObject();
         }catch(Exception e){
              e.printStackTrace();
    %>
    but it tell me Error like this :
    java.io.EOFException :          
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java )
    at java.io.ObjectInputStream$BlockDataInput.readShort(ObjectInputStream.java )
    who can tell me why ????? and tell me how to resolve it ??
    Thanks !!!!!               

    It's not good to send data as serialized data objects to your front end jsp. It'd be better sending data to another servlet/jsp which will process them, probably by saving them in session. After closing the OutputStream, you have to invoke a javascript function in order to make your browser to submit a request to your front end jsp. So you code could be something like:
    out.close();
    // get the JSObject representing the applet's browser window.
    JSObject win = JSObject.getWindow(this);
    // Run JavaScript with eval(). Careful with those nested quotes!
    win.eval("alert('before submit');jspsubmit();");
    Of cource you have to add the jspsumbit() javascript function in the header of your JspDataTest.jsp. It have only to do a submit to itself (or whatever page you like). The jsp which gets this request can get data from the session.

  • Three questions about applets

    First I double click the html file, and then it opens up Internet Explorer but the information bar says:
    To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options... so I click it and have to allow the blocked content.
    Question 1: Is there anything I can do so that it doesn't block my applet?
    Now on the Internet Explorer page my applet shows, but it doesn't have a background.
    Question 2: Why isn't the background showing?
    If there is a problem, it would probably be in here:
    public void actionPerformed (ActionEvent e)
         processButton(e.getActionCommand());
    void processButton(String command)
         if(!command.equals("a"))
                setNumSqFt();
             setAllLabels();
             repaint();
        public void init()
       try
         setLayout(new GridLayout(1, 0));
              WorkOK().setOpaque(false);
                WorkOK().setSize(new Dimension(600, 400));
             JScrollPane sp = new JScrollPane(WorkOK());
              sp.getViewport().setOpaque(false);
         add(sp);
             sp.setOpaque(false);
             String url = "http://i93.photobucket.com/albums/l45/dazednconfused101/tile.gif";
             setSize(800,500);
             setVisible(true);
             Border bckgrnd = new CentredBackgroundBorder(ImageIO.read(new URL(url)));
              sp.setViewportBorder(bckgrnd);
                sp.repaint();
         catch (MalformedURLException e)
                  System.err.println("FileNotFoundException: " + e.getMessage());
         catch (IOException e)
                  System.err.println("Caught IOException: " + e.getMessage());
    public void start(){
         System.out.println("Applet starting.");
      public void stop(){
         System.out.println("Applet stopping.");
      public void destroy(){
         System.out.println("Destroy method called.");
      }Now for Question 3: How do I fix this?
    Thanks in advance

    For Question 1 ,
    Question 1: Is there anything I can do so that it doesn't block my applet?If you want to run active content/applet in all files on your hard disk, then you need to open menu Tools / Internet Options / Advanced tab / Security section and make sure that "Allow active content to run in files on My Computer" is checked.

  • Doubt about applet communicating with the SIM

    Greetings,
    I have this doubt: I am developing a web site which contains a java applet. The web site is going to be available at some web server. The web site is going to be accessed by mobile phones. The idea is that, somehow, the applet communicates with the mobile phone and extract info from the SIM Card for authentication. I still wondering if it is possible and the possible drawbacks or alternatives.
    Thank you in advance,
    Fernando

    Hi,
    you definitely have to sign your applet to do that.
    Check in the forum "Security -> Signed applet". You'll find the information you need to sign an applet.
    For example check at: http://forum.java.sun.com/thread.jsp?forum=63&thread=174214

  • Status about  Applet is loading

    Hi,
    My applet contains scrollpane and on the canvas the graphics were drawn. This applet loads on a browser. But it is taking time to load and i would like to show the status or progress bar so that user can know that applet is loading.
    Thanks in advance
    punni

    This may help:
    public void init() {   
       Container c = getContentPane();
       //create progress bar and loading label
       progressBar = new JProgressBar(0, 7);
       progressBar.setValue(0);
       progressBar.setStringPainted(true);   
       final JPanel progressPanel = new JPanel();
       progressPanel.add(progressBar,BorderLayout.SOUTH);
       JPanel panel = new JPanel(new BorderLayout());
       panel.add(new JPanel(),BorderLayout.NORTH);
       panel.add(new JLabel("<HTML><B>Loading...</B></HTML>",SwingConstants.CENTER),BorderLayout.CENTER);
       panel.add(progressPanel,BorderLayout.SOUTH);
       c.add(panel,BorderLayout.CENTER);
       doTimeConsumingStuff();
    }//end init method
       * Retrieve data from the database and build and display the currently selected Map.
       * Builds a MapData object after retrieving the data from the database. Builds all
       * the panels and adds everything to the Applet so that it can be displayed.                           
       private void doTimeConsumingStuff() {
          final JApplet applet = this;
          //SwingWorker is a class that SUN programmers made. 
          //You can find its code in 'The Java Tutorial'
          final SwingWorker worker = new SwingWorker() {
             * Whatever you put in this method is meant to take awhile.  So,
             * this is the portion that is actually ran in a thread separate from
             * the main thread.
             public Object construct() {
                //do your long stuff here.
                //note, in differring locations of your time-consuming, code, do:
                progressBar.setValue(1);
                progressBar.setValue(6);
                return yourObjectRef; //this can be any object
             }//end construct
             *  Executes all its code in the event-dispatching thread.  We want
             *  the GUI building to be done in the event dispatch thread. 
             *  Because we are using SUN's SwingWorker class, we don't need to
             *  wrap the GUI building portion in a SwingUtilities.invokeLater()
             *  method.  We just put the GUI building in the finished method of
             *  the SwingWorker and it will accomplish the same thing.
             public void finished() {    
                final Container c = getContentPane(); //applet's
                c.removeAll();  //removes the progress bar
                c.add({add your components});
                c.validate();               
             }//end finished
          };//end SwingWorker class
          worker.start();     
       }//end buildMap method

Maybe you are looking for

  • Two 1GB memory modules don't work on MS-7173 board

    Hi, I have an old MS-7173 (RC410M) board, with 1 memory stick of model: Kingston KVR667D2N5/1GB, 1.8v. I bought another memory stick with the exact model. I tried them both, but I get a computer restart once windows starts booting. Each of them works

  • Retrieving values from a JComboBox - Design question.

    I would like some design guidance on a problem that I am hoping has been solved before. Here is my situation: I have a JComboBox that I populate with String values from a database table. The exact set of values to be loaded into the JComboBox varies

  • Oracle SOA Suite Install Error on Vista 64 bit

    Hi All, I am trying to install SOA Suite 10.1.3.1.0 on Vista 64 bit windows. I downloaded Correct version from the Oracle Site. when I click on Setup exe it is throwing following error? "The Version of this is file is not compatible with the version

  • Please help me creating a view

    Hi Guru's Iam trying to write a view to acheive the below o/p CUST_UID MASTER_FLAG GROUP_ID AAAE55 1 001 DDDE55 NULL 001 AE56 1 002 DDE56 NULL 002 AAAE57 1 003 AAAE58 1 004 Expected o/p: CUST_UUID MASTER_UUID GROUP_ID AAAE55 AAAE55 001 DDDE55 AAAE55

  • PrivateDis​k not the same as Drive partition ?

    I want to upgrade my built in Client Security Solution v7 and Rescue and Recovery. I downloaded the applicatons and got stuck in this: I have created two disk partitions on my drive, if I upgrade, will it be possible without merging  the partitions o