SlideShare una empresa de Scribd logo
1 de 6
NetBeans IDE 4.1 Tutorial for Applets
Feedback Feedback
Though there are no project templates that are specifically designed for creating applets in
NetBeans IDE 4.1, you can easily develop them in a Java project and package them in a web
project. The application that you build in this tutorial guides you through the following
activities in NetBeans IDE 4.1:
• Creating or importing an applet source file -- create a Java project, create or
import an applet source file (see the final section if you want to import a JAR file
containing applet source files)
• Running and debugging an applet source file -- run an applet source file, debug
it by modifying its parameters in the src folder
• Embedding an applet in a web application -- create a web project, import a
NetBeans IDE 4.1 Java project or a JAR file containing applet source files, add applet
tags to a JSP file or HTML file, run the web project
• Setting permissions for an applet -- to come
This tutorial can be completed in 20 minutes.
Creating or Importing an Applet Source File
Create the Java project from scratch or from existing sources
1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select General.
2. Choose one of the following:
oIf you are creating a new applet source file, select Java Class Library under
Projects. Click Next.
oIf you want to import an applet source file, select Java Project with Existing
Sources. Click Next. Specify the file's location in the Source Packages
Folder text box.
3. Under Project Name, type HelloApplet. Change the Project Location to any
folder on your computer.
4. Click Finish. If you imported an applet source file, run and debug it.
Create the applet source file
1. Right-click the HelloApplet project node in the Projects window and select New
File/Folder (Ctrl-N).
2. Under Categories, select Java Classes. Under File Types, select Applet. Click Next.
3. Under Class Name, type MyApplet. Under Package, type org.me.hello.
4. Click Finish.
The IDE creates the applet source file in the specified package. The applet source
file opens in the Source editor.
5. Define your applet class by copying and pasting the following code over the
existing default code:
6. package org.me.hello;
7.
8. import java.applet.Applet;
9. import java.awt.Graphics;
10.
11. public class MyApplet extends Applet {
12. public void paint(Graphics g) {
13. g.drawString("Hello applet!", 50, 25);
14. }
15. }
For detailed information on writing applets, see The JavaTM
Tutorial's Writing
Applets section.
Running and Debugging an Applet Source File
Build and run the applet source file
1. Right-click the HelloApplet project node in the Projects window and choose Build
Project from the contextual menu.
2. The HelloApplet.jar file is created in the dist folder.
3. Right-click the applet class node in the Projects window and choose Run File from
the contextual menu.
The MyApplet.html launcher file, with the applet embedded, is created in the
build folder and launched in the Applet Viewer.
Debug the applet source file by modifying its parameters
The MyApplet.html launcher file in your build folder is overwritten each time you run or
debug the applet. Therefore, do not modify the launcher file in your build folder. Instead,
use the following procedure:
1. Open the Files window (Ctrl-2).
2. Copy the MyApplet.html launcher file from the build folder to the package
where the applet class lives in the src folder (in this case, to org.me.hello).
Make sure that the MyApplet.html launcher file has the same name as the
applet class.
3. Now edit the MyApplet.html launcher file as needed.
When you build the project, the MyApplet.html launcher file is copied from the
src folder to the build folder.
Tip: The launcher file is created by the IDE when you run or debug an applet. If
you copy it to your src folder for editing, it will automatically be included in the
JAR file when you build the project. Normally, you do not need to include this file
when you package your application. Exclude the launcher file from the JAR file by
right-clicking the project, choosing Properties, clicking Creating JAR, and adding an
expression to exclude launcher files such as MyApplet.html.
Embedding an Applet in a Web Application
Create the web project
1. Choose File > New Project. Under Categories, select Web. Under Projects, select
Web Application. Click Next.
2. Under Project Name, type HelloWebApplet. Change the Project Location to any
folder on your computer.
3. Click Finish.
Add the applet JAR file to the web project
When you want to include an applet JAR file in a web project, you can do so by adding the
NetBeans IDE 4.1 Java project that contains the JAR file, or by adding the JAR file itself.
Although the choice is yours, note that when you add the NetBeans IDE 4.1 Java project to
the web project, you enable the IDE to build the applet whenever you build the web
application. Therefore, when you modify the applet in the NetBeans IDE 4.1 Java project, the
IDE builds a new version of the applet whenever the web project is built. On the other hand,
if the applet JAR file is not in a NetBeans IDE 4.1 Java project, the applet source file is not
rebuilt when you build the web project.
1. In the Projects window, right-click the HelloWebApplet project node and select
Properties from the contextual menu.
2. Choose one of the following:
oIf the applet JAR file is in a NetBeans IDE 4.1 Java project, click Packaging
Project, and then click Add Project. Browse to and select the folder that
contains the NetBeans IDE 4.1 Java project. Note that NetBeans IDE 4.1
projects are marked by the NetBeans IDE project icon.
oIf the applet JAR file is not in a NetBeans IDE 4.1 project, click Packaging
Project, and then click Add JAR/Folder. Browse to and select the folder that
contains the JAR file.
The JAR file containing the applet source file is listed in a table at the bottom of
the Project Properties dialog box.
3. Optionally, you can type a location for the applet in the table's Path in WAR
column. By default, the applet JAR file will be copied to the web application's
document root, which is the build/web folder (the highest level of the web
application's file structure). Click OK.
When you build the project, the applet's JAR file is packaged in the project's WAR
file in the dist folder. It is also added to the build/web folder. For details, see
the illustration below.
Create and run the JSP file or HTML file
1. Choose one of the following:
oIf you want to embed the applet in a JSP file, double-click the default
index.jsp file in the Projects window. This file is created by the IDE
when you create a web project. It opens in the Source Editor.
oIf you want to embed the applet in an HTML file, right-click the
HelloWebApplet project node, and choose New > File/Folder from the
contextual menu. Under Categories, select Web. Under File Types, select
HTML. Click Next. Give your HTML file a name and click Finish.
2. Embed the applet in the file by adding the following applet tag anywhere between
the file's <body></body> tags:
<applet code="org.me.hello.MyApplet"
archive="HelloApplet.jar"/>
oorg.me.hello.MyApplet is the full classname to your applet
oHelloApplet.jar is the JAR file that contains the applet
3. Right-click the JSP node or HTML node in the Projects window and choose Run File
from the contextual menu.
The server deploys the JSP file or HTML file in the IDE's default browser. You
should see something similar to the illustration below.
Note that applets run in the virtual machine of the IDE's default web browser. The
IDE uses a different virtual machine and therefore applets are not included in a
web application's debug session. Debug the applet within the Java project, as
explained above.
Next Steps
For more information about using NetBeans IDE 4.1, see the following resources:
• NetBeans IDE 4.1 Quick Start Guides:
oFor J2SE Applications
oFor Web Applications
oFor Web Services
oFor J2ME MIDP Applications
• NetBeans IDE 4.1 Import Guides:
oFor J2SE Applications
oFor Web Applications
oFor J2EE Applications
oFor J2ME MIDP Applications
• NetBeans IDE 4.1 Tutorials:
oFor Web Applications
oFor Tag Libraries
• NetBeans IDE Support and Docs page
To send comments and suggestions, get support, and keep informed on the latest
developments on the NetBeans IDE J2EE development features, join the
nbj2ee@netbeans.org nbj2ee @ netbeans.org mailing list . For more information about
upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org . For more
information about upcoming J2EE development features in NetBeans IDE, see
j2ee.netbeans.org .
The server deploys the JSP file or HTML file in the IDE's default browser. You
should see something similar to the illustration below.
Note that applets run in the virtual machine of the IDE's default web browser. The
IDE uses a different virtual machine and therefore applets are not included in a
web application's debug session. Debug the applet within the Java project, as
explained above.
Next Steps
For more information about using NetBeans IDE 4.1, see the following resources:
• NetBeans IDE 4.1 Quick Start Guides:
oFor J2SE Applications
oFor Web Applications
oFor Web Services
oFor J2ME MIDP Applications
• NetBeans IDE 4.1 Import Guides:
oFor J2SE Applications
oFor Web Applications
oFor J2EE Applications
oFor J2ME MIDP Applications
• NetBeans IDE 4.1 Tutorials:
oFor Web Applications
oFor Tag Libraries
• NetBeans IDE Support and Docs page
To send comments and suggestions, get support, and keep informed on the latest
developments on the NetBeans IDE J2EE development features, join the
nbj2ee@netbeans.org nbj2ee @ netbeans.org mailing list . For more information about
upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org . For more
information about upcoming J2EE development features in NetBeans IDE, see
j2ee.netbeans.org .

Más contenido relacionado

Más de Ivan Ramirez Iglesias

Más de Ivan Ramirez Iglesias (7)

(86)resumen visual basic
(86)resumen visual basic(86)resumen visual basic
(86)resumen visual basic
 
Ejercicios desarrollados de visual basic (según libro)
Ejercicios desarrollados de visual basic (según libro)Ejercicios desarrollados de visual basic (según libro)
Ejercicios desarrollados de visual basic (según libro)
 
Diccionario basico de programacion visual basic
Diccionario basico de programacion visual basicDiccionario basico de programacion visual basic
Diccionario basico de programacion visual basic
 
Sq lite
Sq liteSq lite
Sq lite
 
Link guias java y sqlite
Link guias java y sqliteLink guias java y sqlite
Link guias java y sqlite
 
Seminarioacad2013 120912152424-phpapp02
Seminarioacad2013 120912152424-phpapp02Seminarioacad2013 120912152424-phpapp02
Seminarioacad2013 120912152424-phpapp02
 
Aulaycorreo 120906152218-phpapp02
Aulaycorreo 120906152218-phpapp02Aulaycorreo 120906152218-phpapp02
Aulaycorreo 120906152218-phpapp02
 

Último

Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...ritikasharma
 
Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448ont65320
 
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24... Shivani Pandey
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914Delhi Call girls
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls Agency
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls AgencyHire 💕 8617697112 North Sikkim Call Girls Service Call Girls Agency
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls AgencyNitya salvi
 
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...rahim quresi
 
📞 Contact Number 8617697112 VIP East Sikkim Call Girls
📞 Contact Number 8617697112 VIP East Sikkim Call Girls📞 Contact Number 8617697112 VIP East Sikkim Call Girls
📞 Contact Number 8617697112 VIP East Sikkim Call GirlsNitya salvi
 
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...ritikasharma
 
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service Available
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service AvailableCall Girls Bhandara Just Call 8617697112 Top Class Call Girl Service Available
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service AvailableNitya salvi
 
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser... Shivani Pandey
 
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...ritikasharma
 
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034 Independe...
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034  Independe...Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034  Independe...
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034 Independe... Shivani Pandey
 
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...ritikasharma
 
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls Service
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls ServiceCollege Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls Service
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls ServiceNitya salvi
 
Top Rated Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...
Top Rated  Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...Top Rated  Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...
Top Rated Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...Call Girls in Nagpur High Profile
 
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...SUHANI PANDEY
 
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLBhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLNitya salvi
 
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...ritikasharma
 

Último (20)

Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Lake Town ✔ 6297143586 ✔C...
 
Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448
 
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
 
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls Agency
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls AgencyHire 💕 8617697112 North Sikkim Call Girls Service Call Girls Agency
Hire 💕 8617697112 North Sikkim Call Girls Service Call Girls Agency
 
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Sonagachi Call Girls In All Kolkata 24/7 Provide Call W...
 
📞 Contact Number 8617697112 VIP East Sikkim Call Girls
📞 Contact Number 8617697112 VIP East Sikkim Call Girls📞 Contact Number 8617697112 VIP East Sikkim Call Girls
📞 Contact Number 8617697112 VIP East Sikkim Call Girls
 
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
 
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service Available
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service AvailableCall Girls Bhandara Just Call 8617697112 Top Class Call Girl Service Available
Call Girls Bhandara Just Call 8617697112 Top Class Call Girl Service Available
 
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
 
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
Behala ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Ready ...
 
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034 Independe...
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034  Independe...Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034  Independe...
Verified Trusted Call Girls Singaperumal Koil Chennai ✔✔7427069034 Independe...
 
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata ✔ 62971...
 
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls Service
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls ServiceCollege Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls Service
College Call Girls Pune 8617697112 Short 1500 Night 6000 Best call girls Service
 
Top Rated Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...
Top Rated  Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...Top Rated  Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...
Top Rated Pune Call Girls Pimpri Chinchwad ⟟ 6297143586 ⟟ Call Me For Genuin...
 
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...
VIP Model Call Girls Vijayawada ( Pune ) Call ON 8005736733 Starting From 5K ...
 
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRLBhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
Bhimtal ❤CALL GIRL 8617697112 ❤CALL GIRLS IN Bhimtal ESCORT SERVICE❤CALL GIRL
 
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...
Jodhpur Park ( Call Girls ) Kolkata ✔ 6297143586 ✔ Hot Model With Sexy Bhabi ...
 

Netbeans ide 4 1 tutorial for applets

  • 1. NetBeans IDE 4.1 Tutorial for Applets Feedback Feedback Though there are no project templates that are specifically designed for creating applets in NetBeans IDE 4.1, you can easily develop them in a Java project and package them in a web project. The application that you build in this tutorial guides you through the following activities in NetBeans IDE 4.1: • Creating or importing an applet source file -- create a Java project, create or import an applet source file (see the final section if you want to import a JAR file containing applet source files) • Running and debugging an applet source file -- run an applet source file, debug it by modifying its parameters in the src folder • Embedding an applet in a web application -- create a web project, import a NetBeans IDE 4.1 Java project or a JAR file containing applet source files, add applet tags to a JSP file or HTML file, run the web project • Setting permissions for an applet -- to come This tutorial can be completed in 20 minutes. Creating or Importing an Applet Source File Create the Java project from scratch or from existing sources 1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select General. 2. Choose one of the following: oIf you are creating a new applet source file, select Java Class Library under Projects. Click Next. oIf you want to import an applet source file, select Java Project with Existing Sources. Click Next. Specify the file's location in the Source Packages Folder text box. 3. Under Project Name, type HelloApplet. Change the Project Location to any folder on your computer. 4. Click Finish. If you imported an applet source file, run and debug it. Create the applet source file 1. Right-click the HelloApplet project node in the Projects window and select New File/Folder (Ctrl-N). 2. Under Categories, select Java Classes. Under File Types, select Applet. Click Next. 3. Under Class Name, type MyApplet. Under Package, type org.me.hello. 4. Click Finish. The IDE creates the applet source file in the specified package. The applet source file opens in the Source editor. 5. Define your applet class by copying and pasting the following code over the existing default code: 6. package org.me.hello; 7. 8. import java.applet.Applet; 9. import java.awt.Graphics; 10. 11. public class MyApplet extends Applet { 12. public void paint(Graphics g) { 13. g.drawString("Hello applet!", 50, 25); 14. } 15. }
  • 2. For detailed information on writing applets, see The JavaTM Tutorial's Writing Applets section. Running and Debugging an Applet Source File Build and run the applet source file 1. Right-click the HelloApplet project node in the Projects window and choose Build Project from the contextual menu. 2. The HelloApplet.jar file is created in the dist folder. 3. Right-click the applet class node in the Projects window and choose Run File from the contextual menu. The MyApplet.html launcher file, with the applet embedded, is created in the build folder and launched in the Applet Viewer. Debug the applet source file by modifying its parameters
  • 3. The MyApplet.html launcher file in your build folder is overwritten each time you run or debug the applet. Therefore, do not modify the launcher file in your build folder. Instead, use the following procedure: 1. Open the Files window (Ctrl-2). 2. Copy the MyApplet.html launcher file from the build folder to the package where the applet class lives in the src folder (in this case, to org.me.hello). Make sure that the MyApplet.html launcher file has the same name as the applet class. 3. Now edit the MyApplet.html launcher file as needed. When you build the project, the MyApplet.html launcher file is copied from the src folder to the build folder. Tip: The launcher file is created by the IDE when you run or debug an applet. If you copy it to your src folder for editing, it will automatically be included in the JAR file when you build the project. Normally, you do not need to include this file when you package your application. Exclude the launcher file from the JAR file by right-clicking the project, choosing Properties, clicking Creating JAR, and adding an expression to exclude launcher files such as MyApplet.html. Embedding an Applet in a Web Application Create the web project 1. Choose File > New Project. Under Categories, select Web. Under Projects, select Web Application. Click Next. 2. Under Project Name, type HelloWebApplet. Change the Project Location to any folder on your computer. 3. Click Finish. Add the applet JAR file to the web project When you want to include an applet JAR file in a web project, you can do so by adding the NetBeans IDE 4.1 Java project that contains the JAR file, or by adding the JAR file itself. Although the choice is yours, note that when you add the NetBeans IDE 4.1 Java project to the web project, you enable the IDE to build the applet whenever you build the web application. Therefore, when you modify the applet in the NetBeans IDE 4.1 Java project, the IDE builds a new version of the applet whenever the web project is built. On the other hand, if the applet JAR file is not in a NetBeans IDE 4.1 Java project, the applet source file is not rebuilt when you build the web project. 1. In the Projects window, right-click the HelloWebApplet project node and select Properties from the contextual menu. 2. Choose one of the following: oIf the applet JAR file is in a NetBeans IDE 4.1 Java project, click Packaging Project, and then click Add Project. Browse to and select the folder that contains the NetBeans IDE 4.1 Java project. Note that NetBeans IDE 4.1 projects are marked by the NetBeans IDE project icon. oIf the applet JAR file is not in a NetBeans IDE 4.1 project, click Packaging Project, and then click Add JAR/Folder. Browse to and select the folder that contains the JAR file. The JAR file containing the applet source file is listed in a table at the bottom of the Project Properties dialog box.
  • 4. 3. Optionally, you can type a location for the applet in the table's Path in WAR column. By default, the applet JAR file will be copied to the web application's document root, which is the build/web folder (the highest level of the web application's file structure). Click OK. When you build the project, the applet's JAR file is packaged in the project's WAR file in the dist folder. It is also added to the build/web folder. For details, see the illustration below. Create and run the JSP file or HTML file 1. Choose one of the following: oIf you want to embed the applet in a JSP file, double-click the default index.jsp file in the Projects window. This file is created by the IDE when you create a web project. It opens in the Source Editor. oIf you want to embed the applet in an HTML file, right-click the HelloWebApplet project node, and choose New > File/Folder from the contextual menu. Under Categories, select Web. Under File Types, select HTML. Click Next. Give your HTML file a name and click Finish. 2. Embed the applet in the file by adding the following applet tag anywhere between the file's <body></body> tags: <applet code="org.me.hello.MyApplet" archive="HelloApplet.jar"/> oorg.me.hello.MyApplet is the full classname to your applet oHelloApplet.jar is the JAR file that contains the applet 3. Right-click the JSP node or HTML node in the Projects window and choose Run File from the contextual menu.
  • 5. The server deploys the JSP file or HTML file in the IDE's default browser. You should see something similar to the illustration below. Note that applets run in the virtual machine of the IDE's default web browser. The IDE uses a different virtual machine and therefore applets are not included in a web application's debug session. Debug the applet within the Java project, as explained above. Next Steps For more information about using NetBeans IDE 4.1, see the following resources: • NetBeans IDE 4.1 Quick Start Guides: oFor J2SE Applications oFor Web Applications oFor Web Services oFor J2ME MIDP Applications • NetBeans IDE 4.1 Import Guides: oFor J2SE Applications oFor Web Applications oFor J2EE Applications oFor J2ME MIDP Applications • NetBeans IDE 4.1 Tutorials: oFor Web Applications oFor Tag Libraries • NetBeans IDE Support and Docs page To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE J2EE development features, join the nbj2ee@netbeans.org nbj2ee @ netbeans.org mailing list . For more information about upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org . For more information about upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org .
  • 6. The server deploys the JSP file or HTML file in the IDE's default browser. You should see something similar to the illustration below. Note that applets run in the virtual machine of the IDE's default web browser. The IDE uses a different virtual machine and therefore applets are not included in a web application's debug session. Debug the applet within the Java project, as explained above. Next Steps For more information about using NetBeans IDE 4.1, see the following resources: • NetBeans IDE 4.1 Quick Start Guides: oFor J2SE Applications oFor Web Applications oFor Web Services oFor J2ME MIDP Applications • NetBeans IDE 4.1 Import Guides: oFor J2SE Applications oFor Web Applications oFor J2EE Applications oFor J2ME MIDP Applications • NetBeans IDE 4.1 Tutorials: oFor Web Applications oFor Tag Libraries • NetBeans IDE Support and Docs page To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE J2EE development features, join the nbj2ee@netbeans.org nbj2ee @ netbeans.org mailing list . For more information about upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org . For more information about upcoming J2EE development features in NetBeans IDE, see j2ee.netbeans.org .