Solved

How to  create an exit Button in Applet using textpad

Posted on 2001-06-05
16
710 Views
Last Modified: 2008-02-01
hi..

i have created an applet that i would like to create for it an exit button
but i don't know how also i was wondering how can i reset the value of a label that i created.....i would be greatful for ur help.......

ok...to be more clear i want to creat a exit button on my applet a button that will close the applet window
i'm using a textpad 4 utitily to  view the applet... how do i do that.....?????
0
Comment
Question by:ranma51
  • 8
  • 3
  • 2
  • +2
16 Comments
 
LVL 9

Accepted Solution

by:
Ovi earned 100 total points
ID: 6155458
about exit button be more clear about what you want. To reset the text on a label just simply call yourLabel.setText("") or yoourLabel.setText("New text goes here")
0
 

Expert Comment

by:cs98rpm
ID: 6155470
As Ovi says to set your label, text component or whatever to empty you just put in the command call yourLabel.setText("") which sets it to a blank return

For the exit button you will need an ActionEventListener so you can then put in the ActionEvent  System.exit(0);

this will close your applet.

Hope this is of some use to you

Cheers RPM.
0
 
LVL 92

Expert Comment

by:objects
ID: 6155522
Sorry you cannot close an applet. It runs inside another application such as a browser or appletviewer.
Calling System.exit from within an applet will throw a SecurityException.
It doesn't make sense for an applet to be allowed to shutdown your browser.
0
 
LVL 2

Expert Comment

by:mariuso
ID: 6155553
What do you want to do ? To close the entire IE or netscape window ? You can do this with som javaScript called by java applet.

System.exit(0) makes no sens in applet !!!
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155554
You can close the applet by closing the browser window, if this is what you really want. To do so you must use some simple LiveConnect implementation.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155560
You can close the applet by closing the browser window, if this is what you really want. To do so you must use some simple LiveConnect implementation.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155576
mai du-te ba smechere
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155593
When you say the applet window you are refering to the browser window or to a separate applet frame window ?
if(browser.window)
  use LiveConnect
else if(separateWindow)
  separateWindow.addWindowListener(new ExitAdapter());
.....

class ExitAdapter extends WindowAdapter {
  public void windowClosing(WindowEvent we) {
    Window w = we.getWindow();
    w.dispose();
    w = null;
  }
}

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:teast
ID: 6155861
LiveConnect is netscape specific, so it won't work in IE or other browsers.

Using the java applet, you can't close the browser window wherein your applet is running.
you can only open a new window (not a browser window; a java.awt.Frame) and close this
when you want to, but the original browser window (or appletviewer, etc.) will stay open.

you can only switch to something like a suspend mode in your applet. something like displaying a message similar to "this applet is inactive".

regards,
daniel

daniel-strecker@gmx.net
icq#: 54120485
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6155914
Wow !!!! It seems that I'll will get some real points from teast for the LiveConnect method. :-)))))
0
 
LVL 2

Expert Comment

by:mariuso
ID: 6156633
IN YOUR DREAMS ovi :)
0
 

Expert Comment

by:teast
ID: 6156872
maybe that you'll will get some points :-)))

seriously, did i miss something about live connect or similar in ie or why did you write that?
0
 
LVL 92

Expert Comment

by:objects
ID: 6157951
So jumping up and down waving your arms get points these days :-)
0
 

Expert Comment

by:teast
ID: 6158074
are these points any means for an end??? i mean, do they have any sense? would consider offering some points for good answers ;-)
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6159022
For teast :

Live connect is possible in IE like this :

- unidirectional, from html to applet, calling some applet public methods via document.applet['applet_index in page starting with 0'].someAppletPublicMethod(some parameters);
- bidirectional, using for the html->applet comunication the above method and for applet->html comunication using the netscape.javascript.JSObject and netscape.javascript.JSException classes. The price for including this two classes into the applet project is minimal compared with the functionality.

If you take a look at the archives in Windows/Java/... you will find there the above classes included into the Microsoft VM. So the LiveConnect is fully suported in IE too.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6159026
I'm waiting for thwe points NOW :-)))))
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Understanding websocket example in spring 1 54
xampp tool 12 21
Windows 10 IE Certificate Issue 10 41
javap not working 8 35
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now