Solved

getAppletContext error

Posted on 1997-05-08
6
287 Views
Last Modified: 2006-11-17
Continuing with the applet which loooks like it can do everything I need it to- How do I resolve the getAppletContext compile error - please refer to my question
regarding user input to form a url to read a file from a server. Many thanks and Kudos to Mlimotte - you are indeed a Java expert and a fine teacher! Here's the code:
import java.awt.*;
              import java.net.*;
              import java.io.*;

              public class getFile01 extends java.applet.Applet {
                 
                  TextArea text = new TextArea();
                  Button btnOk = new Button("Ok");
                  String server = "abcdefg",
                  url_prefix = "/hijkl/m_",
                  url_suffix = ".txt";


                  public void init() {
                  setLayout(new BorderLayout());
                  add("Center",text);
                  add("South", btnOk);
                  }
                 
                  public boolean action(Event event, Object what)
              {
                  if (event.target == btnOk)
                  {
                 
                  try {
                  URL url = new URL ("http", server,
                  url_prefix + text.getText() + url_suffix);
                  getAppletContext.showDocument(url);
                  }
                  catch (Exception exp) {
                  text.setText("Cannot Load");
                  }
                 
                  return true;
                  }
                  else
                  return super.action(event, what);
                  }

              }
0
Comment
Question by:boksi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:boksi1
ID: 1220243
If you can respond to this can you please cc me at my work email address    usmtgddt@ibmmail.com as well as caesar@netins.net
thank you, Joseph Ruisi
0
 

Author Comment

by:boksi1
ID: 1220244
I forgot to ask but would like to be sure that I am using the assoviated HTML applet tag correctly - can you please comment on this. Thanks, Joseph Ruisi
0
 
LVL 1

Accepted Solution

by:
mlimotte earned 10 total points
ID: 1220245
I answered the compiler error problem as a comment under the original question.

As to your second question, about the HTML tag; you didn't show the HTML that you are trying to use, but here's a sample:

<HTML>
<BODY>
<APPLET CODE="package.class_name.class"
        WIDTH=300
        HEIGHT=200>
</APPLET>
</BODY>
</HTML>

The code name should end in ".class", width and height are mandatory. There are other options that you can use in the APPLET tag which are listed in the documentation.  And you can add paramaters between the <APPLET> and </APPLET> tags.

If you have specfic questions about how to use the <APPLET> tag you can add additional comments.

0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:boksi1
ID: 1220246
Thanks for the response- I am unclear on how the comment to the original question resolves the compiler error. I am confused
because I thought the comment regarded the two applet approach.
Can you please clarify for me how to resolve the
error. I apologize for my ignorance. What exactly do I do to remove the error in the original single applet approach?
I understand getAppletContext(); to be a method. Somehow I am
stumbling.
0
 
LVL 1

Expert Comment

by:mlimotte
ID: 1220247
I've added an additional comment under the original question to clarify what you need to do.  If you'd like to respond, please do it there so we can keep the question threads distinct.
0
 

Author Comment

by:boksi1
ID: 1220248
Yes - In case you haven't looked at my comment on the original
question - getFile compiled successfully and I wil be testing it.
Mlimotte-THANK YOU!!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

724 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