Solved

getAppletContext error

Posted on 1997-05-08
6
284 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 55
ForLoop Example 3 47
difference of if loops 23 49
by zero exception 10 39
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 …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

813 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

11 Experts available now in Live!

Get 1:1 Help Now