Solved

getAppletContext error

Posted on 1997-05-08
6
282 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

706 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

22 Experts available now in Live!

Get 1:1 Help Now