• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading Source Code into a JFrame in an Applet

 
Brendan Thompson
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beginner question here:
Create an applet that loads its own source code in a JFrame.

Sounds weird to me. Is there some sort of method that does this? All I can think of is copying the source code into a txt file and then reading from that.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why copy? You can read a .java file just as easily as a .txt.

I would hazard a guess that what the assignment's really looking for is your ability to locate and access a file based on the running class's name and package structure. Always assuming that the .class and .java are located in the same folder, under the package root (if there's a package statement).

Also note that you don't
Create an applet that loads its own source code in a JFrame.

You display the contents of a text file (yes, a .java file is a text file) in an appropriate JTextComponent which is shown in a JFrame.

I don't see why an Applet should come into the mix, unless part of the test is to launch a JFrame from an Applet.
 
Brendan Thompson
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice on readi.g .java files. And the use of an applet is just to get familiar with creating and implementing them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic