Problem: clicking to exit an applet

Hi there,
I've been given a java assignment. We are to build a java applet. I've got it doing everything it needs to do aside form one thing:
We are supposed to enable the user to click anywhere in the applet , and then the applet closes.
Apparently we were supposed to have been taught how to do this, but were not. Can anybody help me out here as to how this can be done?
Thanks in advance

Don't use System.exit in applet, won't work, and would probably throw a security exception.
Only "destroy" your applet by overriding the destroy() method (where you do some clean up, close open connections, release references that takes a lot of memory, etc, nothing else). This method is called by the browser, at least when you close it.
The stop() method should not try to destroy your applet. I think if the browser calls stop(), it will also call start() to start the applet again, but without calling the init() method. The init() method is called if the browser needs to run your applet first time, or again after destroy() has been called as far as I know.
You can get more info if you read the javadoc comments for those methods.

Similar Messages

  • Right way to exit an applet

    Hi,
    I am making an applet by extending JApplet. Can anyone please tell what's the right way to stop the applet ie. to complete its execution.
    Shoud System.exit() be used, i tried stop and destroy , nothing happened. I have provided a menu inside my applet i want it to exit or complete execution with its window removed when some clicks on exit menu.
    Any suggestion is welcome.
    thanks
    inder

    Don't use System.exit in applet, won't work, and would probably throw a security exception.
    Only "destroy" your applet by overriding the destroy() method (where you do some clean up, close open connections, release references that takes a lot of memory, etc, nothing else). This method is called by the browser, at least when you close it.
    The stop() method should not try to destroy your applet. I think if the browser calls stop(), it will also call start() to start the applet again, but without calling the init() method. The init() method is called if the browser needs to run your applet first time, or again after destroy() has been called as far as I know.
    You can get more info if you read the javadoc comments for those methods.

  • One of the usb devices attached to this computer has malfunctioned, and Windows does not recognize it. For assistance in solving this problem, click this message.

    I connected my sons Ipod Touch to my pc and it worked fine. Now, when I try to connect my iPad the following message comes up: One of the usb devices attached to this computer has malfunctioned, and Windows does not recognize it. For assistance in solving this problem, click this message.
    I checked the cable. It surely is not the cable. If I connect the iPod again it works fine. If I use the same cable with my pc and ipad at work or my other son’s laptop, it is working perfectly. It is only on my laptop where the iPod was connected. Something tells me it got something to do with the drivers that went corrupt or something when I connected the iPod.
    I searched the internet and I see a lot of people gets this message. Still no solved answers yet. Is there a place where I can download the drivers again or any other suggestions?
    Windows 7 and iPad 2
    Kind regards,

    I was hoping it would be something like a USB device conflict, but now the shuffle is the only thing connected...
    This article was one of the ones you linked to above in your initial post
    http://support.apple.com/kb/TS1369
    Under Part 9. Verify that USB drivers are installed, did you try the steps in If only "Unknown Device" appears?  That appears to be your situation.
    Also, you said that the shuffle initially worked well enough to do a sync, then it had the same problem again.  If you can get it to work again initially, before doing anything else, try the following.  Select the shuffle in the iTunes sidebar, under DEVICES.  Over to the right, go to the Summary tab.  By default, the checkbox for Enable disk use should be unchecked.  If so, check it and Apply the change.  See if that makes any difference. 
    (If Enable disk use was already checked, try unchecking it and Apply the change.  Basically, set it the "other way" and see if there is any improvement.)
    NOTE:  When disk use is enabled, you have to eject the iPod in iTunes before disconnecting it physically.
    If the disk use change makes a difference, that may provide a clue about the actual cause.

  • Using iPod shuffle 4th generation for first time and receiving the error : one of the USB devices attached to this computer has malfunctioned, and windows does not recognize it. For assistance in solving this problem, click this message

    Using iPod shuffle 4th generation for first time and receiving the error : one of the USB devices attached to this computer has malfunctioned, and windows does not recognize it. For assistance in solving this problem, click this message.
    Using win 7 and latest iTunes [10.6.3]. Have already gone through below links and did not find any solution.
    http://support.apple.com/kb/HT2292
    http://support.apple.com/kb/TS1369
    http://support.apple.com/kb/HT1923
    http://en.kioskea.net/forum/affich-17997-ipod-not-detected

    I was hoping it would be something like a USB device conflict, but now the shuffle is the only thing connected...
    This article was one of the ones you linked to above in your initial post
    http://support.apple.com/kb/TS1369
    Under Part 9. Verify that USB drivers are installed, did you try the steps in If only "Unknown Device" appears?  That appears to be your situation.
    Also, you said that the shuffle initially worked well enough to do a sync, then it had the same problem again.  If you can get it to work again initially, before doing anything else, try the following.  Select the shuffle in the iTunes sidebar, under DEVICES.  Over to the right, go to the Summary tab.  By default, the checkbox for Enable disk use should be unchecked.  If so, check it and Apply the change.  See if that makes any difference. 
    (If Enable disk use was already checked, try unchecking it and Apply the change.  Basically, set it the "other way" and see if there is any improvement.)
    NOTE:  When disk use is enabled, you have to eject the iPod in iTunes before disconnecting it physically.
    If the disk use change makes a difference, that may provide a clue about the actual cause.

  • Problem in Screen Exit

    Hi all,
    I have a problem in Screen Exit. My requirement is to create one new field in ME21N transaction code, I did that using screen exit, which offers me a tab of Customer Data. That is working fine. My problem here is when the user enters the value in that(costcenter) field tax jurisdication code should populate automatically for the particular entry. I used user exit for this purpose to update taxjurcode field in the table. But after the user exit execution the rest of the program code executes and it updates the EKPO table which over writes the entries which i was updating using my user exit code. How can i get rid off this problem. Please throw some light on that. Thanks.

    You are right. My user exit is also triggering that place only for the ME22n and ME23n...........it is strange for me as it is not working for ME21n. Which is not updating with the statements that i provided in User exits.
      When i am debugging the program after the user exit it is taking me to some std program where the entries were overwritten. That is where i face the problem.
    Any suggestions.

  • End of Slide Show click to exit in between Presenetation

    Dear All,
    There is a 60 Pages Presentation in Power Point 2010. But when i running this, getting errors as ënd of slide show, click to exit " in between slide show even though my presentation not finished.
    Any suggestion about this error. 

    Hi,
    As this question is more relate to Office, I suggest you post it to Microsoft Office Forum, you will get more help and confirmed answers from there.
    http://social.technet.microsoft.com/Forums/office/en-US/home<o:p></o:p>
    Best regards
    Dennis Guo
    TechNet Community Support

  • Lightroom problem with the exit button...

    In Lightroom, the window got redesigned in such a way that you can't move the cursor to the absolute top right corner and click to exit like you can in standard windows--you have to aim with the cursor on the exit button which is annoying.

    Just stumbled over the thread.
    Interesting how these discussions evolve.
    Someone points out an unexpected behavior. LR doesn't act conform with every other app on pc. Instead of accept this, people start argueing whether it is necessary to close apps in general, bla bla.
    Why not admit: Yes there is a flaw. There are workarounds, so it's not a deal breaker. We would like to have this addressed by adobe in the next version. It doesn't matter if there are users that never use the cross to close apps. It doesn't matter if there are other ways to close.
    Why change standards? This may be unintentionally here but there are other examples.
    The crop tool in LR.
    The Keyboard shortcuts. In every Adobe Application. I never understood, why there are no 2 adobe-apps that share the same shortcuts. Even standards like ctrl-ins/shift-ins does not work in for exyample in indesign. Drives me nuts. No, I don't want to use use ctrl-c/ctrl-v. I use my mouse with my left hand.
    Copy settings in LR. Ctrl-Shift-C. No other app uses this.
    Why change established standards??

  • Captivate TOC navigate visited slide only problem. Visited topic can not click when exit and open again the training.

    Hi,
    I have created the TOC and i want the learner just can click at the Topic they have visited. i have no problem at the first time viewing the training.
    The problem is i read half of the training, for example I have Topic 1 - Topic 5, I just read until Topic 3 finish, then I exit the training. When i reenter the training, the Topic 1 - Topic 3 which i have already visited can not click, I can not review back those topic. At the TOC setting, I have enabled the Self-Paced Learning, Enabled Navigation, Navigate Visited Slides Only.
    Is there any other setting I need to enable to make the learner can click at the topic they have visited when they exit and reopen the training?
    Thanks,
    Chee SK

    I don't think you are understanding what I'm saying.
    If you are using an LMS then the bookmarking you are currently using MUST be Resume Data bookmarking.  It's the ONLY kind Captivate has that will work with LMSs.
    If you are unable to navigate to a visited topic after resuming from the LMS then it's possible you've got some other setting in your project that is interferring with that navigation.  For example, if you have NOT allowed Backward Movement in your Quiz Settings, then under certain circumstances that will mean you cannot navigate because resuming the lesson dumps you somewhere in the middle of the quiz and you're not allowed (by the settings) to go to an earlier slide.
    Is that what you are seeing?

  • Problem with JPanel, CardLayout and Applets

    Hello All,
    I have a JPanel with a CardLayout as layout manager. In this JPanel i'm gonna show a few applets.
    My problem is when i'm showing an applet for second time and try to click a button it does nothing... I think the action method is not called again...
    How can i solve this?
    Thanks in advance ; )

    Here is a few parts of my code...
    public class InitAll{
    JPanel cards = new JPanel( new CardLayout() );
    JComboBox selector = new JComboBox();
    Object objetosV[][] ={
         {"Ventas",venta.class},
         {"Compras",compras.class}, //These are applets.
         {"Traspasos",traspasos.class},
         {"Facturas",factura.class},
    public void load( Applet app ){
    cards.removeAll();
    selector.removeAll();
    cards.add( "Entrada", app );
    selector.addItem( "Entrada" );
    for ( int i=0; i < objetosV.length; i++ ){
         selector.addItem( (String)objetosV[0] );
         Applet temp=createPanel( ( Class ) objetosV[i][1] );
         temp.setSize( 800,750 );
         cards.add( ( String ) objetosV[i][0], temp );
    public void itemStateChanged(ItemEvent e) {
    ((CardLayout)cards.getLayout()).show(cards, selector.getSelectedItem().toString() );
    Applet tmp = (Applet)cards.getComponent(selector.getSelectedIndex() );
    tmp.start();
    After i show for second time an Applet and select a button from it. the button does nothing...
    Thanks...

  • Problem with JRE and Yahoo applets

    Hi, I couldn't find any answer for this anywhere else...
    Whenever I try to play a Yahoo game, certain windows will "shake". For example, if I log into yahoo, then go to play their spades game, the applet will load without any problem. The game room will appear and everything seems to be fine. But if I click on the Start Panel, the borders of the Start menu will "shake" If I right click on anything, that menu will also shake. This only occurs while JRE is running the yahoo applet. Once I leave the yahoo game, everything returns to normal. If I use IE and MSVM, this problem does not occur. This problem does not seem to occur with other instances of Java either. Only Yahoo games. I tried searching Yahoo for an answer to this, but didn't find anything. When I tried getting help from them, they replied with an email to update Java and/or my browsers. Well, I am using version 1.4.2_04 of java, and have IE6 updated as of today. Also, I am using Opera version 7.54 and Firefox 0.93. This problem with Java and Yahoo occurs no matter which browser I am using. The only way to keep this from happening seems to be to use IE with MSVM. Any ideas?

    That page does apply. Everything that you have written indicates conclusively that the Yahoo game you're playing is the source of the problem. The fact that it works with the MS jvm but not with the Sun jvm, that the Sun jvm works with other Java applets, etc all say the same thing - that Yahoo applets wer/are coded to work with the MS jvm, which uses MS extensions in violation of the Sun/MS licensing agreements. The statement at the bottom of the page is proof positive - your spades game is not listed by Yahoo as being fixed.
    "07/17/03 - From Yahoo! Customer Care:
    We have deployed a fix for the incompatibilities with the Sun JVM� in the following games:
    Chess Gin Cribbage Euchre Bridge
    Hearts Toki Toki Boom Graffiti Pool
    We plan to upgrade the rest of the games on an ongoing basis. "
    The Yahoo applet is the problem and requires repair...

  • JmenuItem not going away when I click outside of the applet

    Hi guys,
    I created a swing applet with JMenu and JMenuItem. If I click within the applet area, the JMenuItem will go away. But when I click out side of the applet, the JMenuItem will not disapear. How to fix this problem?
    Thanks in advance.
    yj

    OK, here are the main parts. First your class must implement the FocusListener interface:
    public MyClass extends JFrame implements FocusListener {
    next you must add the FocusListener:
    myJMenuItem.addFocusListener( this );
    and finally you must implement the two methods focusGained and focusLost:
    public void focusGained( java.awt.event.FocusEvent fe ) {
    Object source = fe.getSource();
    if ( source == myJMenuItem ) {
    //you don't need to really do anything here.
    public void focusLost( java.awt.event.FocusEvent fe ) {
    Object source = fe.getSource();
    if ( source == myJMenuItem ) {
    myJToolBar.repaint(); //Or something to reset it
    Essentially you are checking for when the focus is lost on the JMenubar, you might try using the focus listener on the menu item and if that doesn't work they using it on the toolbar, or even the main frame. Once the focus is lost the focusLost method is called you want to reset your menu bar and repaint it.

  • Numeric value variable problem with user exit

    Dear experts,
    I've created a variable (numeric value, user exit) and I want to get the value of variable from an user exit.
    Actually, I want to convert "0calyear" to a number to be albe to calculate (multiplying, dividing etc).
    If there is a possible solution only in FOX, the solution will be the best. However I couldn't find anything.
    So, the next solution I am trying is user-exit. But I am in stuck here.
    The problem is that I have no idea whether the numeric value variable has any sturcture like other variables(char. value) or not. If yes, what structure it has?
    I know, the characterisc value variables have the structure as blow,
        ls_varsel-chanm =
        ls_varsel-seqno =
        ls_varsel-sign  =
        ls_varsel-opt   =
        ls_varsel-low   =
    I've tried several times with the same way like above, but it doesn't work when I call the variable in "BPS0" or "UPSPL".
    How can I solve it? Please let me know.
    I am using SEM_BW 4.00.
    Many Thanks.
    Bruce

    Hi Ravi,
    Sorry, there's a correction. <b>var2 is used for getting the first month of the year selected by the user in var1</b>. If the user doesn't enter a value for var1, then var2 should take first month of current year from var1 which has by default last month of current year (populated in i_step1 from sy-datum). The user can select the value of var1 according to his requirement. Then var 2 should get first month of the year selected. That's why I'm using two exit variables.
    It works fine during the initial run of the query. But when the user clicks on the variable button in the toolbar and executes the query, var1 is not being displayed and an error message <i>No value could be determined for var2</i> is shown. All other variables used in the query are displayed except var1.
    Krzys, Is the option <i>Can be changed in Query Navigation</i>  available for Exit variables. I'll check that and get back to you.
    Boujema, Thanks for the OSS note.
    Thanks
    Hari

  • Problem in user - Exit for VF01?

    Hi all,
    I have a requirement where i need to calucate the condition value for my billing document and pass the same value to Net value of the billing header also. Here there is no sales order in the flow.
    I am using the exit   USEREXIT_PRICING_PREPARE_TKOMK in the program RV60AFZZ . The calculation is working fine and the net value of the billing header is changing. But if click on any button on screen or saving the billing document the value is not saving and set back to 0?
    Please help me to resolve the problem?
    Thanks,
    Aravind.

    This may be because there are more than one entry points in exit USEREXIT_PRICING_PREPARE_TKOMK i.e the code written in this will be executed varoius time . SO, you need to code in such a way that desired code get executed only for your senario.
    As per my understanding , when you click your button  user exit USEREXIT_PRICING_PREPARE_TKOMK get executed and may be by initial quantity of some field and hence net quantity becomes zero.
    Check this by puutting a breakpoint in USEREXIT_PRICING_PREPARE_TKOMK and check when all it get executed and then ristrict its execution as per your need.
    Hope you get it.

  • Problem with JFile Chooser in applet. help please!!!

    i am making a button for an applet that starts a JFileChooser. it works ok when i start it with the applet viewer in eclipse, but when i put my applet in HTML code and start it in a web browser the JFileChooser Doesn't start. i can click the button but it is like it does nothing. i have read on the forums that it is becouse the browser security doesnt let it execute. so how can i make it work?
    here is the code for the button:
    private JButton getSlikaodberijButton() {
              if (slikaodberijButton == null) {
                   slikaodberijButton = new JButton();
                   slikaodberijButton.setBounds(new Rectangle(0, 0, 136, 28));
                   slikaodberijButton.setText("&#1048;&#1079;&#1073;&#1077;&#1088;&#1080;");
                   slikaodberijButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             JFileChooser dlg = new JFileChooser("&#1048;&#1079;&#1073;&#1077;&#1088;&#1080; &#1057;&#1083;&#1080;&#1082;&#1072;");
                             if (dlg.showDialog(getContentPane(), "&#1048;&#1079;&#1073;&#1077;&#1088;&#1080; &#1057;&#1083;&#1080;&#1082;&#1072;") ==
                             JFileChooser.APPROVE_OPTION){
                             strSlika = dlg.getSelectedFile().toString();
                             ImageIcon ico = new
                             ImageIcon(dlg.getSelectedFile().toString());
                             Image img = ico.getImage();
                             img = img.getScaledInstance(136, 124,Image.SCALE_SMOOTH);
                             ico = new ImageIcon(img);
                             slika=new ImageIcon(img);
                             previewjLabel.setIcon(ico);
              return slikaodberijButton;
         }

    i am making this applet for a school project. the code i have sent is the only thing that is making a problem in the applet. signing an applet seems like a very long process and i read from pkwooster's link that it involves buying a certificate or forging one, placing it on the client computer, and using a dozen of tools. is there a simple way to avoid this signing or a different method to choose a file from a local computer.

  • Exiting an Applet

    Hi, I was just wondering if anyone knows how I might be able to close my applet from a Jbutton event? System.exit(0); doesn't work with an applet it seems. If anyone can let me know how to close and applet in response to a user clicking a Jbutton I would appreciate it. Thanks...

    I think (not sure) if you call the stop() or destroy() methods of your applet it will unload itself. Although if it is in a web page the section set aside for it should still be there.
    Interesting question. Just out of curiosity why do you want to unload the applet?

Maybe you are looking for