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?

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.

  • 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.

  • Exiting an applet with a QUIT button

    Hi all,
    Please excuse me if this questions has been asked 1001 times before.
    I am creating a quit button in a trusted applet, but it seems that the System.exit(0) call is not permitted, with the following message:
    "Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM)"
    Any comments will be much appreciated!

    It is a JApplet.
    In fact, there is not even a client machine, because
    JVM is started on the host itself , an XP OS.Then that machine is the client.
    My objective is to be able to close all applet
    windows of the JApplet using a button, instead of
    having to kill the window manually, which I consider
    to be less <graceful>.
    Basically, I look for the equivalent of
    System.exit(0) using JFrame.You'll have to exit the browser-window which loaded the applet . You cannot close another application through Java.

  • Problem with focus on applet  - jvm1.6

    Hi,
    I have a problem with focus on applet in html page with tag object using jvm 1.6.
    focus on applet work fine when moving with tab in a IEbrowser page with applet executed with jvm 1.5_10 or sup, but the same don't work with jvm1.6 or jvm 1.5 with plugin1.6.
    with jvm 1.5 it's possible to move focus on elements of IEbrowser page and enter and exit to applet.
    i execut the same applet with the same jvm, but after installation of plugin 1.6, when applet gain focus don't release it.
    instead if i execute the same applet with jvm 1.6, applet can't gain focus and manage keyevent, all keyevent are intercepted from browser page.
    (you can find an example on: http://www.vista.it/ita_vista_0311_video_streaming_accessibile_demo.php)
    Any idea?
    Thanks

    Hi piotrek1130sw,
    From what you have described, I think the best approach would be to restore the original IDT driver, restart the computer, test that driver, then install the driver update, and test the outcome of installing the newest driver.
    Use the following link for instructions to recovery the ITD driver using Recovery Manager. Restoring applications and drivers.
    Once the driver is restored, restart the computer and test the audio. If the audio is good you can continue to use this driver, or you can reinstall the update and see what happens. IDT High-Definition (HD) Audio Driver.
    If installing the newest driver causes the issue to occur but the recovered driver worked, I suggest recovering again.
    If neither driver works I will gladly follow up and provide any assistance I can.
    Please let me know the outcome.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • LookAndFeel issue reloading an Applet in a Web page

    Hey all,
    I have an Applet that runs on a web page (loaded by servlets and JSP's using Tomcat 3.2.1 and Apache). I created my own LookAndFeel class and have a static function in the applet that sets the LookAndFeel to my new class. Everything works fine when the Applet is first loaded. However, when you exit the applet and then reload it, the custom LookAndFeel is gone and all I get is the default Metal. If I load the applet with appletviewer, I can reload it as much as I want and it always loads my LookAndFeel class.
    The static function is as follows
    /** Static initializer to set the LookAndFeel
    static {
    try {
    UIManager.setLookAndFeel(new MyNewLookAndFeel());
    catch (Exception e) {}
    I do not get any exceptions and like I said, everything works great when loaded with appletviewer.
    I have tried adding the SwingUtilities.updateComponentTreeUI(this); in either the start(), init(), or my own createGUI() function and it still does not work.
    Any ideas? Could this be a problem with the browser caching the applet? I am using IE 5.50.

    I have the same problem
    putting them in static doesn't keep the look and feel
    putting them in the applet constructor does'nt keep it
    putting them in init() doesn't keep it
    putting them in start() doesn't keep it
    heck, even putting them in all 4 of them together doesn't keep the look and feel, it always reverts back to metal

  • Unable to get Gnome-Keyring working with nm-applet

    Hi guys
    I've installed openbox and using NetworkManager/nm-applet to manage my network connections.
    I prefer it over other utils as it has good support for mobile connections etc.
    I'm using qingy as my login manager.
    I have added the following to /etc/pam.d/qingy
    auth optional /lib/security/pam_gnome_keyring.so
    session optional /lib/security/pam_gnome_keyring.so auto_start
    and the following to /etc/pam.d/passwd
    password optional pam_gnome_keyring.so
    as per the network manager wiki http://wiki.archlinux.org/index.php/Net … fter_login
    I have the following in my session login script:
    nm-applet --sm-disable &
    I think if I remember correctly, the Gnome keyring dialog popped up once or twice in the beginning, but now it never happens. nm applet now always requests my WPA key upon login.
    My intention is to have the key stored in gnome-keyring so that I don't have to enter it every time I log in.
    Any help would be greatly appreciated.

    Hi dieghen89
    Nice to know I'm not the only one pulling out hair over here
    I was playing around and did the following:
    1. Exit nm-applet completely
    2. $ gnome-keyring-daemon --start //I know that the daemon is running. --help states that it starts or initialize an already running daemon
    3. Run nm-applet again
    And the keyring dialog actually did pop up asking for the password to unlock it.
    Now I thought a quick-fix would be to add gnome-keyring-daemon --start to my startup script before nmapplet &
    But alas. doesn't work

  • Applet in a browser page  doesn't gain focus with JVM 1.6.x

    Hi,
    I have a problem to move TAB in a IE browser page with applet in a tag object using JVM 1.6.x
    with JVM 1.5_10 or above this is possible. You can move focus between elements page and enter and exit to applet object.
    Executing the same applet with the same JVM, but after installation of the latest 1.6 plugin, when applet gains focus it doesn't release it.
    With JVM 1.6, applet can't gain focus and manage keyevents; all keyevents are intercepted from browser (eg: IE toolbar elements are activated) .
    I need to move focus on elements of browser page with tab, and enter and exit from applet to make my application accessible event not using mouse !!
    (you can watch a recorder right sample here: http://www.vista.it/ing_vista_0311_video_streaming_accessibile_demo.php)
    Note that FireFox doesn't work at all, even if bug seems fixed https://bugzilla.mozilla.org/show_bug.cgi?id=93149
    Please advise.

    Hi,
    We have found a wor around for this problem.
    The following option has been unchecked and the applet could be loaded.
    Go to java control panel
    Under the Advanced Tab
    Under the Security section
    Uncheck the last option "Use TLSv1.0".
    This makes the applet work.
    But could not understand as why this is creating a problem.
    We have tried to include TLSv1.0 in the cipher suite of our apache server, while keeping the above option in java plugin control panel checked, but even that did not solve the problem.
    Please help me of how should I proceed for this problem, as I am totally stuck.
    Thank you.

  • Background image/reloading/closing applet

    2 questions:
    1) How do I put a background gif/jpg image on a frame window?
    2) Is there a method or command that can restart or reload the current applet?
    3) What's the best normal way to kill/exit the applet? (System.exit() ?)
    What about browser, how do I close the applet in the browser.
    Appreciate any help.
    Regards,
    Helix
    http://www27.brinkster.com/helixical

    I think if you understand Applet's life cycle clearly you'll find answers to questions 2 and 3:
    init() - initializes the applet for the first time.
    start() - starts the applet after initialization and after every time it was stopped. (answer for your Q2)
    paint() - does the actual painting of the applet.
    stop() - stops the applet (kind of temporary), can be restarted anytime.
    destroy() - kills the applet once for all. (answer for your Q3, call this whenever you want the applet to be destroyed).
    answer to Q1, try the following:
    in init():
    MediaTracker tracker = new MediaTracker (this);
    bgImage = getImage (new URL(getCodeBase(), getParameter("bgImage")));
    tracker.addImage (bgImage, 0);
    tracker.waitForAll();
    public void update( Graphics g) {
    paint(g);
    public void paint(Graphics g) {
    if(bgImage != null) {
    int x = 0, y = 0;
    while(y < size().height) {
    x = 0;
    while(x< size().width) {
    g.drawImage(bgImage, x, y, this);
    x=x+bgImage.getWidth(null);
    y=y+bgImage.getHeight(null);
    else {
    g.clearRect(0, 0, size().width, size().height);
    happy trying...
    iDriZ

  • Reloading an Applet Window

    Hi all,
    I have an applet running inside a browser. Users login and do some work and then logout.
    This is what I want:
    When users logout I want to reload my url so that users will be presented with the applet login screen again.
    Basically, I want to call the same url from my applet when some one exits my applet.
    how would I do this ??
    Your help is very much appreciated in advance.
    Ramesh

    try
    getAppletContext().showDocument(url, "_self");

  • Exit.addActionListener

    Hello,
    I am running a applet in Windows ME.
    I am using this code in order to exit from applet:
    I am running the applet using command AppletViewer
         exit.addActionListener( new ActionListener() {
    public void actionPerformed(ActionEvent ev) {
    System.exit(0);     
    But i am getting this output when i try to click on the bottom Exit:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission
    exitVM)
    at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:
    399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkExit(SecurityManager.java:765)
    at java.lang.Runtime.exit(Runtime.java:91)
    at java.lang.System.exit(System.java:701)
    at AppletLibreria$13.actionPerformed(AppletLibreria.java:640)
    at java.awt.Button.processActionEvent(Button.java:329)
    at java.awt.Button.processEvent(Button.java:302)
    at java.awt.Component.dispatchEventImpl(Component.java:2593)
    at java.awt.Component.dispatchEvent(Component.java:2497)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:131)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:98)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    What can i do in order to fix this please ???
    Any help is greatly appreciated.

    You got a SecurityException.
    This happen because the checkExit of your security manager doesn't allow exit with the status you provide (0).
    Now, the class Runtime define the exit method as follow:
        public void exit(int status) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkExit(status);
         Shutdown.exit(status);
        }Accordingly to the Javadoc (see java.lang.SecurityManager#checkExit), if you override this method, then you should make a call to super.checkExit at the point the overridden method would normally throw an exception.

  • How to access the sql database in applet?

    How to access the sql database in applet?
    Please help me.

    import java.applet.*;
    import java.awl.*;
    import java.sql.*;
    //other packages
    public class jdb extends Applet
    Connection con;
    Statement stmt;
    String name="drvijay";
    String phoneno="9842088860";
    public void init(){}
    pubilc void stop(){}
    public void destroy(){}
    public void start()
    call();
    public void call()
    try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn=DriverManager.getConnection("Jdbc:Odbc:emp","sa","");
              stmt=conn.createStatement();
              stmt.executeUpdate("insert into empdetails(name,phoneno) values ('"+name + "',''"+ phoneno +"' )" );
              }catch(SQLException e)
                   System.out.println("error"+e);
                   System.exit(0);
    //<applet code="jdb" height="200" width="200"> </applet>
    u this jdbc statement in any of the method..
    */

  • Help with excel to applet

    don't know why i have a error
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Insets;
    import java.awt.Label;
    import java.awt.LayoutManager;
    import java.awt.TextArea;
    import java.awt.TextField;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JOptionPane;
    import java.text.*;
    import java.awt.Choice;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import java.util.*;
    public class MortgageAppletGUI extends Applet {
             Button calculateButton;
             Button clearButton;
             Button exitButton;
             Button excelButton;
              TextField principalField;
              TextField interestField;
              TextField termField;
              TextArea displayArea;
              Label principal;
              Label term;
              Label interest;
              Image house;
              Font title = new Font("TimesRoman", Font.BOLD, 16);
              Font text = new Font("Courier", Font.BOLD, 12);
              double monthlyInt;
              double monthlyPayment;
              int months=12;
              double interestPayment;
              double principalPayment;
              double remainingBalance;
             Choice principalChoice;
             Choice interestChoice;
             Choice termChoice;
    public static final String DRIVER_NAME =
            "sun.jdbc.odbc.JdbcOdbcDriver";
    public static final String DATABASE_URL = "jdbc:odbc:employee_xls";
    public void init() {
            MortgageAppletLayout customLayout = new MortgageAppletLayout();
              setFont(new Font("Helvetica", Font.PLAIN, 12));
              setLayout(customLayout);
              calculateButton = new Button("Calculate");
              calculateButton.addActionListener(new CalculateActionListener());
              add(calculateButton);
              displayArea = new TextArea();
              add(displayArea);
              principal = new Label("Principal");
              add(principal);
              interest = new Label("Interest");
              add(interest);
              term = new Label("Term");
              add(term);
              clearButton = new Button("Clear");
              clearButton.addActionListener(new CancelActionListener());
              add(clearButton);
              principalField = new TextField(20);
              add(principalField);
              interestField = new TextField(20);
              add(interestField);
              termField = new TextField(20);
              add(termField);
            principalChoice = new Choice();
              principalChoice.addItem("200000");
              principalChoice.addItemListener(new ChoicePrincipal());
            add(principalChoice);
            interestChoice = new Choice();
            interestChoice.addItem("5.35");
            interestChoice.addItem("5.5");
            interestChoice.addItem("5.75");
            interestChoice.addItemListener(new ChoiceInterest());
            add(interestChoice);
            termChoice = new Choice();
            termChoice.addItem("7");
            termChoice.addItem("15");
            termChoice.addItem("30");
            termChoice.addItemListener(new ChoiceTerm());
            add(termChoice);
            exitButton = new Button("Exit");
              exitButton.addActionListener(new ExitActionListener());
              add(exitButton);
            excelButton = new Button("Chart");
              excelButton.addActionListener(new ExcelActionListener());
              add(excelButton);
              setSize(getPreferredSize());
              house = getImage(getCodeBase(), "house.jpg");
    class CalculateActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e) {
              NumberFormat Currency = NumberFormat.getCurrencyInstance();
              String userInputprincipal = principalField.getText();
              String userInputinterest = interestField.getText();
              String userInputterm = termField.getText();
              double userInputprincipalD=0;
              double userInputinterestD=0;
              double userInputtermD=0;
              try {
              userInputprincipalD = Double.parseDouble(userInputprincipal);
              } catch (Exception ex) {
              JOptionPane.showMessageDialog(null, "Error principalField", "Exception 01", JOptionPane.ERROR_MESSAGE);
              principalField.requestFocus();
              return;
              try {
              userInputinterestD = Double.parseDouble(userInputinterest);
              } catch (Exception ex) {
              JOptionPane.showMessageDialog(null, "Error interestField", "Exception 02", JOptionPane.ERROR_MESSAGE);
              interestField.requestFocus();
              return;
              try {
              userInputtermD = Double.parseDouble(userInputterm);
              } catch (Exception ex) {
              JOptionPane.showMessageDialog(null, "Error termField", "Exception 03", JOptionPane.ERROR_MESSAGE);
              termField.requestFocus();
              return;
    // Display principal, interest, and loan balance of entire term
                 double monthlyInt;
                 double monthlyPayment;
                 double interestPayment;
                 double principalPayment;
                 double remainingBalance;
                 double months = userInputtermD * 12;
                 monthlyInt = (userInputinterestD  / 100) / 12;
                 monthlyPayment = (userInputprincipalD * monthlyInt) / (1 - Math.pow(1 / (1 + monthlyInt), userInputtermD  * 12));
                 for (int i = 1; i <= months; ++i) {
             interestPayment = userInputprincipalD * monthlyInt;
             principalPayment = monthlyPayment - interestPayment;
             remainingBalance = userInputprincipalD - principalPayment;
             displayArea.append("\n#" + i + "\tP=" + Currency.format(principalPayment) + "\tI=" + Currency.format(interestPayment)
               + "\tB=" + Currency.format(remainingBalance) + "\n");
             userInputprincipalD -= principalPayment; // calculate until payments are done
    class ExcelActionListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
          Class.forName(DRIVER_NAME);
          Connection con = null;
          try {
             con = DriverManager.getConnection(DATABASE_URL);
             Statement stmt = con.createStatement();
             ResultSet rs = stmt.executeQuery
             ("select lastname, firstname, id from [Sheet1$]");
             while (rs.next()) {
             String lname = rs.getString(1);
             String fname = rs.getString(2);
             int id = rs.getInt(3);
             displayArea.append(fname + " " + lname + "  id : " + id);
             rs.close();
             stmt.close();
               catch(Exception ex) {
               finally {
              try
            if (con != null)
            con.close();
    catch(SQLException ignored) {
    class CancelActionListener implements ActionListener{
    public void actionPerformed(ActionEvent e) {
              principalField.setText("");
              interestField.setText("");
              termField.setText("");
              displayArea.setText("");
    class ExitActionListener implements ActionListener {
    public void actionPerformed(ActionEvent e){
    System.exit(0);
    class ChoicePrincipal implements ItemListener {
    public void itemStateChanged(ItemEvent ie) {
              Choice cb1 = (Choice)ie.getSource(); // the source of the event is the combo box
              String principalC = (String)cb1.getSelectedItem();
              principalField.setText(principalC);
    class ChoiceInterest implements ItemListener {
    public void itemStateChanged(ItemEvent ie) {
              Choice cb1 = (Choice)ie.getSource(); // the source of the event is the combo box
              String interestC = (String)cb1.getSelectedItem();
              interestField.setText(interestC);
    class ChoiceTerm implements ItemListener {
    public void itemStateChanged(ItemEvent ie) {
              Choice cb1 = (Choice)ie.getSource(); // the source of the event is the combo box
              String termC = (String)cb1.getSelectedItem();
              termField.setText(termC);
    public void paint(Graphics g) {
              // Display program info
              g.drawImage(house, 10, 5, this);
              g.setColor(Color.green);
              g.drawLine(20, 4, 230, 4);
              g.setColor(Color.red);
              g.setFont(title);
              g.drawString("\tMortgage Loan Calculator", 10, 17);
              g.setColor(Color.black);
              g.setFont(text);
              g.drawString("\tCreated by Me", 10, 30);
    public static void main(String args[]) {
            MortgageAppletGUI applet = new MortgageAppletGUI();
            Frame window = new Frame("MortgageApplet");
            window.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
            System.exit(0);
            applet.init();
            window.add("Center", applet);
            window.pack();
            window.setVisible(true);
    class MortgageAppletLayout implements LayoutManager {
        public MortgageAppletLayout() {
        public void addLayoutComponent(String name, Component comp) {
        public void removeLayoutComponent(Component comp) {
        public Dimension preferredLayoutSize(Container parent) {
            Dimension dim = new Dimension(0, 0);
            Insets insets = parent.getInsets();
            dim.width = 648 + insets.left + insets.right;
            dim.height = 375 + insets.top + insets.bottom;
            return dim;
        public Dimension minimumLayoutSize(Container parent) {
            Dimension dim = new Dimension(0, 0);
            return dim;
        public void layoutContainer(Container parent) {
            Insets insets = parent.getInsets();
            Component c;
            c = parent.getComponent(0);
            if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+280,72,24);}
            c = parent.getComponent(1);
            if (c.isVisible()) {c.setBounds(insets.left+248,insets.top+88,328,216);}
            c = parent.getComponent(2);
            if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+104,72,24);}
            c = parent.getComponent(3);
            if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+152,72,24);}
            c = parent.getComponent(4);
            if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+128,72,24);}
            c = parent.getComponent(5);
            if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+280,72,24);}
            c = parent.getComponent(6);
            if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+104,72,24);}
            c = parent.getComponent(7);
            if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+128,72,24);}
            c = parent.getComponent(8);
            if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+152,72,24);}
            c = parent.getComponent(9);
            if (c.isVisible()) {c.setBounds(insets.left+152,insets.top+104,72,24);}
            c = parent.getComponent(10);
            if (c.isVisible()) {c.setBounds(insets.left+152,insets.top+128,72,24);}
            c = parent.getComponent(11);
            if (c.isVisible()) {c.setBounds(insets.left+152,insets.top+152,72,24);}
            c = parent.getComponent(12);
            if (c.isVisible()) {c.setBounds(insets.left+172,insets.top+280,50,24);}
                c = parent.getComponent(13);
            if (c.isVisible()) {c.setBounds(insets.left+172,insets.top+380,50,24);}
    }

    The only concern I would have in that is that sometimes there are preparatory or cleanup methods invoked behind the scenes before or after the method you write. For example, you never call myThread.run(), you call myThread.start();
    I tried pasting your code into Eclipse but Eclipse gave lots of errors. And in order to investigate these errors, I'd have to be able to read your code, but you have no indentations so it's a bit hard to do.

  • What is wrong with my applet

    hi;
    i wrote this applet but it didn't work only with opera 8?
    so why only opera?
    package editeur;
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    import java.io.*;
    //Use double buffering to remove rectangle flickers and make it repaint faster.
    public class ShapeMover extends JApplet{
        static protected Label label = new Label(
                "Drag rectangle around within the area");
        MyCanvas mycanvas = new MyCanvas();
        BarreOutils barre=new BarreOutils();
        public static ColorChooserDemo barreCouleur=new ColorChooserDemo();
         public static  XMLayout xml=new XMLayout();
        public void init() {
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(BorderLayout.CENTER,mycanvas);
            getContentPane().add(BorderLayout.WEST, barre);
            getContentPane().add(BorderLayout.EAST, barreCouleur);
        public static void main(String s[]) {
            JFrame f = new JFrame("ShapeMover");
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
            Applet applet = new ShapeMover();
            f.getContentPane().add("Center", applet);
            applet.init();
            f.pack();
            f.setSize(new Dimension(550, 250));
            f.show();
    /code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    maybe opera's the only one with the classes - won't even compile for me
    C:\TestApplet.java:15: cannot find symbol
    symbol  : class MyCanvas
    location: class TestApplet
    MyCanvas mycanvas = new MyCanvas();
    ^
    C:\TestApplet.java:16: cannot find symbol
    symbol  : class BarreOutils
    location: class TestApplet
    BarreOutils barre=new BarreOutils();
    ^
    C:\TestApplet.java:17: cannot find symbol
    symbol  : class ColorChooserDemo
    location: class TestApplet
    public static ColorChooserDemo barreCouleur=new ColorChooserDemo();
                  ^
    C:\TestApplet.java:18: cannot find symbol
    symbol  : class XMLayout
    location: class TestApplet
    public static XMLayout xml=new XMLayout();
                  ^
    C:\TestApplet.java:15: cannot find symbol
    symbol  : class MyCanvas
    location: class TestApplet
    MyCanvas mycanvas = new MyCanvas();
                            ^
    C:\TestApplet.java:16: cannot find symbol
    symbol  : class BarreOutils
    location: class TestApplet
    BarreOutils barre=new BarreOutils();
                          ^
    C:\TestApplet.java:17: cannot find symbol
    symbol  : class ColorChooserDemo
    location: class TestApplet
    public static ColorChooserDemo barreCouleur=new ColorChooserDemo();
                                                    ^
    C:\TestApplet.java:18: cannot find symbol
    symbol  : class XMLayout
    location: class TestApplet
    public static XMLayout xml=new XMLayout();
                                   ^
    C:\TestApplet.java:39: cannot find symbol
    symbol  : class ShapeMover
    location: class TestApplet
    Applet applet = new ShapeMover();
                        ^
    Note: C:\TestApplet.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    9 errors
    Process completed.Message was edited by:
    Michael_Dunn
    change file structure - easier to read

  • How to change a background to an image? and how to put a 'clear' button.

    Hi guys, im new here & i really newbie in java. Recently i found code for java applet that can draw a line. I want put image as a background and draw some lines over the image and provide a button to clear the lines. Is there any one can help me to solve my problem. Here is the code :
    import java.awt.*;
    import java.applet.*;
    public class DrawLines extends Applet {
        //Variables
        Point Start[] = new Point[20];   //X,Y info of start of lines
        Point End[] = new Point[20];     //X,Y info of end of lines
        Point current_start;
        Point current_point;
        int numlines= 0;
        Point boundary;   //to represent the boundary of the applet
        //Set background to yellow, register listeners
        // get boundary of applet
        public void init() {
          setBackground(Color.white);
          current_point = null;
          boundary = new Point(this.size().width,this.size().height);
        //Mouse Clicked Down...save in current_start
        public boolean mouseDown(Event e, int x, int y) {
           if(numlines < 20) {
              current_start = new Point(x,y);
              return true; }
           else
             { System.out.println("Can Not Take Any More Input Lines");
               return false; }
        //Mouse Drag....reset current_point to current position
        public boolean mouseDrag(Event e, int x, int y) {
            if(numlines <20) {
              current_point = new Point(x, y);
              repaint();  //will draw this current line
              return true;
            else
              return false;
        //Mouse Up ...save created line if can and call repaint
        //  to draw it.  Make sure the end point is inside the applet
        public boolean mouseUp(Event e, int x, int y) {
           if( (numlines < 20) && (x < boundary.x) &&
               (y < boundary.y) )
             {  Start[numlines] = current_start;
                End[numlines] = new Point(x, y);
                numlines++;
                //Reset current points to empty
                current_point = null;
                current_start = null;
                //repaint will draw all lines including this one
                // just created.
                repaint();
                return true;
           else
             return false;
        //Draw all of the lines stored in Start[], End[].
        //Draw the current line from current_start to current_point
        public void paint(Graphics g) {
             //set drawing color
             g.setColor(Color.red);
             //Draw stored lines
             for (int i=0; i<numlines; i++) {
                g.drawLine(Start.x, Start[i].y,
    End[i].x, End[i].y);
    //Draw current line if one exists
    g.setColor(Color.blue);
    if (current_point != null)
    g.drawLine(current_start.x, current_start.y,
    current_point.x, current_point.y);
    //Set numlines back to zero
    public void start() {
    numlines=0;
    //In case mouse exits the applet region...reset current points
    public boolean mouseExit(Event e, int x, int y) {
    current_point = null;
    return true; }
    and this is code in HTML
    <HTML>
    <HEAD>
    </HEAD>
    <BODY BGCOLOR="Grey">
    <CENTER>
    <APPLET
         code     = "DrawLines.class"
         width     = "500"
         height     = "500"
         >
    </APPLET>
    </CENTER>
    </BODY>
    </HTML>
    Thanks & appreciate for the help.

    Hey thanks, but i find another way by looking other ppl code for image back ground. And its working! but i still dont know how to create the button (im so very noob in java sigh)
    The link u gave to me is very good but its hard for very newbie like me to understand. I just change the code like this :
    Using offscreen image
    Image off, back;      //to represent background image
         Graphics offG;          //to represent offscreen image                          
        public void init() {
         off = createImage(getSize().width, getSize().height);      // create your offscreeen image
         offG = off.getGraphics();
         back = getImage(getDocumentBase(),"images/Area.jpg");     // load your background image
        current_point = null;
        boundary = new Point(this.size().width,this.size().height);
    // Draw all of the lines stored in Start[], End[].
        // Draw the current line from current_start to current_point
        public void paint(Graphics g) {
              offG.drawImage(back, 0, 0, this);      // draw everything to your off screen first
              g.drawImage(off, 0,0, this);          // copy your off screen to on screen now
            g.setColor(Color.red);                    // set drawing color
            //Draw stored lines
            for (int i=0; i<numlines; i++) {
                g.drawLine(Start.x, Start[i].y,
    End[i].x, End[i].y);
    //Draw current line if one exists
    g.setColor(Color.blue);
         if (current_point != null)
    g.drawLine(current_start.x, current_start.y,
    current_point.x, current_point.y);
    Now my problem is the 'clear' button, i really dun know how to make button which is can clear the lines. Any one have idea?

Maybe you are looking for

  • Cannot connect to PPPoE?  fibre optic Internet in Japan

    Hi I live in Japan All the manuals and helplines are in tricky Japanese and I can't find out why I can't connect to the Internet! Help! I get a message saying "cannot connect to the PPPoE server". It was working fine for a few months but now suddenly

  • Cache Contents are Obsolete after activating BPM

    Hello. I have made a BPM for a scenario, and after activating it, the SXI_CACHE shows: Cache Contents are Obsolete the problem is solved only after I delete the Cache instance in the integration directory, and make a cache connectivity test. The vers

  • IPhone 4S battery indicator won't update.

    I noticed several times that the battery percentage in my iPhone 4S didn't change for hours (i.e. it didn't update properly). For example, I noticed that it stayed at 100% the whole morning today. I just restarted the phone. The battery % changed fro

  • Ubuntu, Disk, Media Kit, help me :(

    Using the disk utility, I have successfully installed Ubuntu OS on it's own 10 GB Partition(s). That's awesome and all, however, after running the installation, I wanted to install XP as well. So as I went to make another 10 GB free space on the same

  • Tab page select

    Hi All I've posted this question a short while ago, but had no response, so I'm trying again with a very stripped down piece of code. The attached vi is a simple one. It simply scrolls through 2 pages with a tab control, and reutrns to front page. I'