How do I turn my existing Java code into an applet?

I have a number of Java classes that run a GUI from one main class.  How do i go about turning my application into an applet???

what classes do I need to change and how should I go about changing them?  any advice would be great?
need_help_plsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You just need to make sure that your previous code doesn't violate applet security restrictions mainly. see http://java.sun.com/sfaq/

If you are not opening any files, sockets or that kind of thing, you should be OK.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
need_help_plsAuthor Commented:
my application does open files...  will that cause major problems??? just read access to the files though...??
0
need_help_plsAuthor Commented:
how can I go about running the application as an applet though??  if all was well?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

CEHJCommented:
You'll have to recode the way it does that. They will have to be in the applet's codebase too, i.e. you can't wander outside that applet's own location in the directory tree.
0
CEHJCommented:
(that is without signing or modification to the security policy)
0
CEHJCommented:
>>how can I go about running the application as an applet though??  

In a browser or appletviewer
0
need_help_plsAuthor Commented:
>>how can I go about running the application as an applet though??  

In a browser or appletviewer


---- but is there some modification that I need to make to my existing code for this to be feasible?? when I view some exsiting applet code that i have seen, they all seem to run this init() method - what is this about?
0
CEHJCommented:
Yes, broadly speaking, you can see init() as being equivalent to your application's constructor and main() to the applet's start() method.
0
need_help_plsAuthor Commented:
ok im not having much success with this... i have created my applet and running it from a basic html page but this is what i get:
my gui appears but opens as a separate application, i.e. as if i had run it independently... it is not part of the html page?!? - i assumed it would be

also, my application no longer works... for example i have a textfield that when input is entered and the user hits return, the text is supposed to be processed by the application and changes made to them gui but nothing happens and i do not get any errors either?!?!??!  HELP
0
need_help_plsAuthor Commented:
i have probably gone wrong, but i basically just wrote my main method again within the init()
eg:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/** A class that allows testing of interpreter, its GUI and the GUIs controller
 * (listener).
 * @author
 */

public class InterpreterMain extends JApplet
{
     public void init(){
          Interpreter interpreter = new Interpreter();
          InterpreterController controller = new InterpreterController();
          InterpreterGUI gui = new InterpreterGUI(controller);
          controller.setInterpreter(interpreter);
          controller.setGUI(gui);


        /* GUIs are simply subclasses of JPanel, so we add the GUI
           to a JFrame and make the JFrame visible.
        */

          JFrame frm = new JFrame("JIN - Java Interpreter for Novice Programmers");
          Container contentPane = frm.getContentPane();
          contentPane.add(gui);

          JMenuBar menuBar = new JMenuBar();
          JMenu fileMenu = gui.makeMenu();
          menuBar.add(fileMenu);
          frm.setJMenuBar(menuBar);

          frm.addWindowListener(new WindowAdapter()
               {  public void windowClosing(WindowEvent we)
                  {  System.exit(0);
                  }
               });

          frm.pack();
          frm.setSize(700, 550);
          //frm.setSize(900, 600);
          frm.setVisible(true);

     }
     public static void main(String[] args)
     {
          /* Create interpreter, interpreter GUI and controller
          */

          Interpreter interpreter = new Interpreter();
          InterpreterController controller = new InterpreterController();
          InterpreterGUI gui = new InterpreterGUI(controller);
          controller.setInterpreter(interpreter);
          controller.setGUI(gui);


        /* GUIs are simply subclasses of JPanel, so we add the GUI
           to a JFrame and make the JFrame visible.
        */

          JFrame frm = new JFrame("JIN - Java Interpreter for Novice Programmers");
          Container contentPane = frm.getContentPane();
          contentPane.add(gui);

          JMenuBar menuBar = new JMenuBar();
          JMenu fileMenu = gui.makeMenu();
          menuBar.add(fileMenu);
          frm.setJMenuBar(menuBar);

          frm.addWindowListener(new WindowAdapter()
               {  public void windowClosing(WindowEvent we)
                  {  System.exit(0);
                  }
               });

          frm.pack();
          frm.setSize(700, 550);
          //frm.setSize(900, 600);
          frm.setVisible(true);

     }
}
0
CEHJCommented:
>>opens as a separate application, i.e. as if i had run it independently... it is not part of the html page?!? - i assumed it would be


No. You use a frame, so it'll look like an application.

As far as the operation of the GUI is concerned, i can't comment on the problems there as the processing code doesn't appear in your post.
0
need_help_plsAuthor Commented:
so to make the application just appear on the webpage i should not create a JFrame just add the components to the applet??  should this be done in init() or my main method of InterpreterMain??

The operation of the GUI works perfectly when run as a standard Java application that is why I didnt post the code... when I run it in a browser it doesnt work at all - when i run it in an applet viewwer it works perfectly also... its just that i need it to be able to be displayed in a browser window, i assume the problem stems from the fact that i open files for reading in my application and have not made any allowances for this when using the browser but i am not sure what allowances i need to make?
0
need_help_plsAuthor Commented:
so to make the application just appear on the webpage i should not create a JFrame just add the components to the applet??  should this be done in init() or my main method of InterpreterMain??

The operation of the GUI works perfectly when run as a standard Java application that is why I didnt post the code... when I run it in a browser it doesnt work at all - when i run it in an applet viewwer it works perfectly also... its just that i need it to be able to be displayed in a browser window, i assume the problem stems from the fact that i open files for reading in my application and have not made any allowances for this when using the browser but i am not sure what allowances i need to make?
0
CEHJCommented:
>>just add the components to the applet??  should this be done in init()

Yes and yes. AFAIK JApplet uses a BorderLayout by default so just treat your applet like the JFrame

>>
i assume the problem stems from the fact that i open files for reading in my application and have not made any allowances for this when using the browser
>>

Exactly what i would have guessed. The workaround here is
a. Instead of File, create a URL to the resoruce you want to read and get an input stream on it to read it.
b. Make sure the resource is in your applet's codebase
0
need_help_plsAuthor Commented:
Sorry - yet another problem:

what do i do for the following...  i need to open a html file, which again works fine in the application, but not in the applet???

here is the code i am using currently:

     /**
      * Creates the help Panel
      *
      * @return thePanel ... the panel to be created
      */
     public JPanel createHelp()
     {
          JPanel thePanel = new JPanel();
          thePanel.setBorder(BorderFactory.createTitledBorder("Help"));

          ImageIcon back = new ImageIcon("back.jpg");
          JButton backBtn = new JButton(back);
          helpLbl = new JLabel(HELP_SELECT);

          try
          {
               ep = new JEditorPane("http://student.cs.ucc.ie/03/ekc1/projectHelp/test.html");
               ep.setPreferredSize(new Dimension(375,350));
               //ep.setPage(FILENAME);
          }
          catch (IOException ioe)
          {
               System.out.println(ioe.getMessage());
          }
          ep.setEditable(false);
          ep.addHyperlinkListener(new HyperlinkListener()
               {
                  public void hyperlinkUpdate(HyperlinkEvent he)
                  {
                       if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                       {
                            JEditorPane pane = (JEditorPane) he.getSource();
                            try
                            {
                                 pane.setPage(he.getURL());
                            }
                            catch (IOException ioe)
                            {
                                 System.out.println(ioe.getMessage());
                            }
                       }
                  }
               });
         
         
          backBtn.addActionListener(new ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
                    try
                    {
                         ep = new JEditorPane("http://student.cs.ucc.ie/03/ekc1/projectHelp/test.html#index");
                    }
                    catch (IOException ioe)
                    {
                         System.out.println(ioe.getMessage());
                    }
            }
        });

         
          JScrollPane viewer = new JScrollPane(ep);

          GridBagLayout gbl = new GridBagLayout();
          GridBagConstraints gbc = new GridBagConstraints();
          thePanel.setLayout(gbl);
          gbc.fill = GridBagConstraints.BOTH;
          gbc.anchor = GridBagConstraints.CENTER;
          gbc.insets = new Insets(4, 4, 4, 4);
          addComp(helpLbl, thePanel, gbl, gbc, 0, 0, 1, 150, 0, 0);
          //addComp(backBtn, thePanel, gbl, gbc, 0, 150, 1, 1, 0, 0);
          addComp(viewer, thePanel, gbl, gbc, 1, 0, 400, 400, 0, 0);

          return thePanel;
     }
0
CEHJCommented:
Is your applet being served from http://student.cs.ucc.ie?
0
need_help_plsAuthor Commented:
yeah.. applet is served from student.cs.ucc.ie
0
CEHJCommented:
Comment out the ImageIcon bit and let me know what happens
0
need_help_plsAuthor Commented:
the same - makes no difference...
when i hit the help btn in the gui my controller calls the above method create help, when i hit the help btn i get errors along the lines of :

java.security.AccessControlException: access denied (java.net.SocketPermission s
tudent.cs.ucc.ie resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
        at java.security.AccessController.checkPermission(AccessController.java:
401)
0
CEHJCommented:
OK. I think you'll have to eliminate the potential problems one at a time, so comment out one thing at a time.
Try empty constructor and getStream on the editor pane
0
need_help_plsAuthor Commented:
ok:

sorry bout this its just that this is part of my final year project that is due to present on thursday so im kind of scared now:

my applet still doesnt work in the browser i have made the following changes below, and still all that happens is that it loads but wont work...

also, i still cannot get the help button to work in the applet viewer, however when i run it in the browser the panel will display but none of the links work????

im really confused!?!?!  any help would be great? emergency...

     public InputStream getData(String filename) throws Exception
     {
          InputStream is = null;
          try
          {
               //The applet is being run locally
               is = new FileInputStream(filename);
          }
          catch (SecurityException se)
          {
               //The applet is being run across the internet
               //getDocumentBase();
               //URL current = getDocumentBase();
               URL current = new URL("http://student.cs.ucc.ie/03/ekc1/project/GUIstuff/run.html");
               URL cgi = new URL(current.getProtocol(),
               current.getHost(), current.getPort(),

               current.getPath()+"/cgiread.cgi?filename="+filename);
               URLConnection con = cgi.openConnection();
               con.setDoOutput(true);
               con.setDoInput(true);
               con.setUseCaches(false);
               con.setRequestProperty("Content-type","text/plain");

               PrintStream out = new PrintStream(con.getOutputStream());
               out.print(filename);
               out.flush();
               out.close();
               
               is = con.getInputStream();
          }
          return is;
     }

     
     /**
      * Checks that the variable name supplied is valid
      * @return boolean
      */
     public boolean checkName(String theText)
     {
          try
          {
               BufferedReader validName = new BufferedReader(new InputStreamReader(getData("validChar.txt")));
               
               String letter = new String();
               
               while(validName.ready())
               {
                    StringTokenizer letterStk = new StringTokenizer(validName.readLine(), "\n");
                    letter = (String)letterStk.nextToken();
                   
                    if(theText.startsWith(letter))
                    {
                         return true;
                    }
               }
               if(!validName.ready())
               {
                    validName.close();
                    validName = new BufferedReader(new InputStreamReader(getData("validChar.txt")));
               }

               validName.close();
               return false;

          }
          catch(Exception ioe)
          {
               System.out.println("File not found");
               ioe.printStackTrace();
               return false;
          }
         
     }


where cgiread.cgi is:
#!/usr/bin/perl

@values = split(/&/,$ENV{'QUERY_STRING'});
foreach $i (@values) {
    ($varname, $mydata) = split(/=/,$i);
    if ($varname == "filename")
    {
        $filename = $mydata;
    }
}

open(INFO, $filename);
@array=<INFO>;
close (INFO);
print "Content-type: text/plain\n\n";
foreach $line (@array)
{
print $line;
}
exit;
0
CEHJCommented:
OK. The first thing you must do is to pay very close attention to the stack trace of any Exceptions. Check the plugin console
0
need_help_plsAuthor Commented:
im so sorry this is going to soud like a very silly question, it is just that i have never written/used any applet before, but how do i check the console when i am running the applet from a browser?
so not sure how to check what the problem is when i run it in the browser??

but, when i run it in the appletviewer i dont get any errors when running it until i hit the help button which gives: (i dont understand this error really - )

java.security.AccessControlException: access denied (java.net.SocketPermission s
tudent.cs.ucc.ie resolve)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
        at java.security.AccessController.checkPermission(AccessController.java:
401)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
        at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
        at java.net.InetAddress.getAllByName0(InetAddress.java:909)
        at java.net.InetAddress.getAllByName0(InetAddress.java:890)
        at java.net.InetAddress.getAllByName(InetAddress.java:884)
        at java.net.InetAddress.getByName(InetAddress.java:814)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:282)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:253)
        at sun.net.www.http.HttpClient.New(HttpClient.java:321)
        at sun.net.www.http.HttpClient.New(HttpClient.java:306)
        at sun.net.www.http.HttpClient.New(HttpClient.java:301)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:469)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:460)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:562)
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:237
)
        at javax.swing.JEditorPane.getStream(JEditorPane.java:674)
        at javax.swing.JEditorPane.setPage(JEditorPane.java:392)
        at javax.swing.JEditorPane.setPage(JEditorPane.java:775)
        at javax.swing.JEditorPane.<init>(JEditorPane.java:249)
        at InterpreterGUI.createHelp(InterpreterGUI.java:362)
        at InterpreterGUI.helpFrame(InterpreterGUI.java:337)
        at InterpreterController.actionPerformed(InterpreterController.java:64)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
67)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1820)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:258)
        at java.awt.Component.processMouseEvent(Component.java:5021)
        at java.awt.Component.processEvent(Component.java:4818)
        at java.awt.Container.processEvent(Container.java:1525)
        at java.awt.Component.dispatchEventImpl(Component.java:3526)
        at java.awt.Container.dispatchEventImpl(Container.java:1582)
        at java.awt.Component.dispatchEvent(Component.java:3367)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
        at java.awt.Container.dispatchEventImpl(Container.java:1568)
        at java.awt.Component.dispatchEvent(Component.java:3367)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:191)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:144)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

0
CEHJCommented:
OK, you can test it in appletviewer at first and then move to the browser later. Are you connecting outside your codebase in InterpreterGUI.createHelp(InterpreterGUI.java:362)?
0
need_help_plsAuthor Commented:
(InterpreterGUI.java:362)
ep = new JEditorPane("http://student.cs.ucc.ie/03/ekc1/projectHelp/test.html");


I run this code when using an appletviwer from my home directory on ocean(student.cs.ucc.ie), then a copy of this folder is uploaded to /csweb/03/ekc1/project/ which is ocean's web repository.  projectHelp/test.html is just another directory within that web repository.  All the code is identical to what is in my home directory.  When I run the code in my home directory, it does, as you can see above access the on-line version of test.html.

When i run in using an appletviewer from my home directory the aforementioned result of clicking the help btn occurs.  The java application works.
0
need_help_plsAuthor Commented:
(InterpreterGUI.java:362)
ep = new JEditorPane("http://student.cs.ucc.ie/03/ekc1/projectHelp/test.html");


I run this code when using an appletviwer from my home directory on ocean(student.cs.ucc.ie), then a copy of this folder is uploaded to /csweb/03/ekc1/project/ which is ocean's web repository.  projectHelp/test.html is just another directory within that web repository.  All the code is identical to what is in my home directory.  When I run the code in my home directory, it does, as you can see above access the on-line version of test.html.

When i run in using an appletviewer from my home directory the aforementioned result of clicking the help btn occurs.  The java application works.
0
CEHJCommented:
In that case, you haven't followed my suggestion from earlier:

>>Try empty constructor and getStream on the editor pane
0
CEHJCommented:
You should construct the URL argument to that function as follows:

URL url = new URL(getCodeBase(), "somefile");

Find out what getCodeBase() returns so you can form the URL properly.
0
need_help_plsAuthor Commented:
sorry im not sure that i understand?  Im just looking at the apis for getStream and not sure how you mean me to use it..??
you mean the constructor for the EditorPane should be
ep = new JEditorPane();
but how do i go about setting the page then? using getStream?
0
CEHJCommented:
URL url = new URL(getCodeBase(), "somefile");
ep.getStream(url);

i think!
0
need_help_plsAuthor Commented:
Z:\Project\GUIstuff>javac *.java
InterpreterGUI.java:365: cannot resolve symbol
symbol  : method getCodeBase  ()
location: class InterpreterGUI
                        URL url = new URL(getCodeBase(), "test.html");
                                          ^
InterpreterGUI.java:366: getStream(java.net.URL) has protected access in javax.s
wing.JEditorPane
                        ep.getStream(url);
                          ^
2 errors
0
CEHJCommented:
getCodeBase() needs to be in applet's scope.

Sorry - try setPage with that code instead of getStream
0
need_help_plsAuthor Commented:
uh-oh!  this code is all in my GUI class - I am not creating the applet here.  I have a separate class InterpreterMain that orignally invoked the GUI, that now creates the applet....  is there anyway around this??
0
CEHJCommented:
Pass the applet as a parameter to an appropriate constructor.
0
need_help_plsAuthor Commented:
I will try and explain that better.  my applet opens fine in the appletviewer and runs ok - the only problem i have with it in the applet viewer is when i hit the help button.  What should happen is that my actionlistener is my controller class will call gui.createHelp() which is the method pasted above that the code snipets are from.  this works fine in the applcation but not in the appletviwer.  (in the browser the editorpane loads but the link dont work - if that sheds any light on the matter)

ps:  I realise this must be very annoying, but i cant say how much i appreciate you taking the time for this - cant ask any class mates as they are all very busy too - so on my own and really stressed now - 1 day to go - arrrrggghhh!!! (maybe i should rethink my career choice!!!?!?!)   : )
0
need_help_plsAuthor Commented:
this is where i create the applet - how else should i do it if i need to pass it as a param to the gui class (if i picked up what you said correctly??)

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/** A class that allows testing of interpreter, its GUI and the GUIs controller
 * (listener).
 * @author Katie Crowley 99037190 ekc1@student.cs.ucc.ie
 */

public class InterpreterMain extends JApplet
{
     public void init(){
          Interpreter interpreter = new Interpreter();
          InterpreterController controller = new InterpreterController();
          InterpreterGUI gui = new InterpreterGUI(controller);
          controller.setInterpreter(interpreter);
          controller.setGUI(gui);


        /* GUIs are simply subclasses of JPanel, so we add the GUI
           to a JFrame and make the JFrame visible.
        */

          //JFrame frm = new JFrame("JIN - Java Interpreter for Novice Programmers");
          Container contentPane = this.getContentPane();
          contentPane.add(gui);

          JMenuBar menuBar = new JMenuBar();
          JMenu fileMenu = gui.makeMenu();
          menuBar.add(fileMenu);
          this.setJMenuBar(menuBar);

          /*this.addWindowListener(new WindowAdapter()
               {  public void windowClosing(WindowEvent we)
                  {  System.exit(0);
                  }
               });

          this.pack();*/
          this.setSize(700, 550);
          //frm.setSize(900, 600);
          this.setVisible(true);

     }
     public static void main(String[] args)
     {
          /* Create interpreter, interpreter GUI and controller
          */

          Interpreter interpreter = new Interpreter();
          InterpreterController controller = new InterpreterController();
          InterpreterGUI gui = new InterpreterGUI(controller);
          controller.setInterpreter(interpreter);
          controller.setGUI(gui);


        /* GUIs are simply subclasses of JPanel, so we add the GUI
           to a JFrame and make the JFrame visible.
        */

          JFrame frm = new JFrame("JIN - Java Interpreter for Novice Programmers");
          Container contentPane = frm.getContentPane();
          contentPane.add(gui);

          JMenuBar menuBar = new JMenuBar();
          JMenu fileMenu = gui.makeMenu();
          menuBar.add(fileMenu);
          frm.setJMenuBar(menuBar);

          frm.addWindowListener(new WindowAdapter()
               {  public void windowClosing(WindowEvent we)
                  {  System.exit(0);
                  }
               });

          frm.pack();
          frm.setSize(700, 550);
          //frm.setSize(900, 600);
          frm.setVisible(true);

     }
}
0
CEHJCommented:
Don't worry - these security constrictions are a pain!

>>the only problem i have with it in the applet viewer is when i hit the help button.  

My guess is it's down to the way the url is created, a suggested solution to which i've just given
0
CEHJCommented:
Maybe here?

>>InterpreterGUI gui = new InterpreterGUI(controller);

as

>>InterpreterGUI gui = new InterpreterGUI(controller, this);

0
need_help_plsAuthor Commented:
but the applet is created in InterpreterMain??
sorry the confusion is probably due to the fact that i have been looking at this code everyday for the past few months and now im just all over the place!?!?
0
need_help_plsAuthor Commented:
my labs are closing now, so I will check the site again in the morning.  hopefully things will be a bit clearer for me then also - thanks again, (goodnight/day whatever part of globe!!!)
0
CEHJCommented:
>>but the applet is created in InterpreterMain??

The applet reference is in scope here, so you should have no problem:

>>InterpreterGUI gui = new InterpreterGUI(controller, this);
0
need_help_plsAuthor Commented:
ok, so i changed the constructor for interpreterGUI to take it the applet and then ran it in the appletviewer with the following results:

java.lang.NullPointerException
        at InterpreterGUI.createHelp(InterpreterGUI.java:367)
        at InterpreterGUI.helpFrame(InterpreterGUI.java:339)
        at InterpreterController.actionPerformed(InterpreterController.java:64)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
67)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1820)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:258)
        at java.awt.Component.processMouseEvent(Component.java:5021)
        at java.awt.Component.processEvent(Component.java:4818)
        at java.awt.Container.processEvent(Container.java:1525)
        at java.awt.Component.dispatchEventImpl(Component.java:3526)
        at java.awt.Container.dispatchEventImpl(Container.java:1582)
        at java.awt.Component.dispatchEvent(Component.java:3367)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
        at java.awt.Container.dispatchEventImpl(Container.java:1568)
        at java.awt.Component.dispatchEvent(Component.java:3367)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:191)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:144)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
0
CEHJCommented:
Then you probably haven't passed the reference on properly to the InterpreterGUI.
0
need_help_plsAuthor Commented:
in InterpreterMain i have changed to :
public class InterpreterMain extends JApplet
{
     public void init()
     {
          Interpreter interpreter = new Interpreter();
          InterpreterController controller = new InterpreterController();
          InterpreterGUI gui = new InterpreterGUI(controller,this);
.... etc etc
}}

and in InterpreterGUI:

public InterpreterGUI(InterpreterController theController, JApplet j)
   {
      super();
       
       myApplet = j;
       
      /* Store the interpreter controller */
      controller = theController;
etc etc...
}

and in InterpreterGUI.createHelp()
               URL url = new URL(myApplet.getCodeBase(), "test.html");
               ep.setPage(url);
0
CEHJCommented:
Is this line 367?

>>URL url = new URL(myApplet.getCodeBase(), "test.html");
0
need_help_plsAuthor Commented:
line 367 = ep.setPage(url);
0
CEHJCommented:
1. Is ep valid?
2. Did you make sure that getCodeBase() returns what you think it does as i suggested before?
0
need_help_plsAuthor Commented:
code base returns :  file:/Z:/Project/GUIstuff/

ep should be valid... i have it declared as
private JEditorPane ep;
0
CEHJCommented:
1. I mean is the refence null, obviously
2. Is this url valid?
file:/Z:/Project/GUIstuff/test.html
0
need_help_plsAuthor Commented:
IT WORKS NOW!!!!!! not sure why but am so happy that it does!!!!!!   maybe i should just leave it run in the appletviewer???  would it be very difficult to get it working in the browser??? thank you sooooo much - im so grateful!!!!!!!!!
0
CEHJCommented:
>>not sure why

Why not? Surely you know what you've changed!?
0
CleanupPingCommented:
need_help_pls:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to CEHJ

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.