Previous     Contents     Index     Next     
Core JavaScript Reference 1.5





JavaClass

A JavaScript reference to a Java class.


Core object  

 

Implemented in  

JavaScript 1.1, NES 2.0  


Created by
A reference to the class name used with the Packages object:

Packages.JavaClass

where JavaClass is the fully-specified name of the object's Java class. The LiveConnect java, sun, and netscape objects provide shortcuts for commonly used Java packages and also create JavaClass objects.


Description
A JavaClass object is a reference to one of the classes in a Java package, such as netscape.javascript.JSObject. A JavaPackage object is a reference to a Java package, such as netscape.javascript. In JavaScript, the JavaPackage and JavaClass hierarchy reflect the Java package and class hierarchy.

You can pass a JavaClass object to a Java method which requires an argument of type java.lang.Class.


Backward compatibility

JavaScript 1.3 and earlier. You must create a wrapper around an instance of java.lang.Class before you pass it as a parameter to a Java method-JavaClass objects are not automatically converted to instances of java.lang.Class.


Property Summary
The properties of a JavaClass object are the static fields of the Java class.


Method Summary
The methods of a JavaClass object are the static methods of the Java class.


Examples
Example 1. In the following example, x is a JavaClass object referring to java.awt.Font. Because BOLD is a static field in the Font class, it is also a property of the JavaClass object.

x = java.awt.Font
myFont = x("helv",x.BOLD,10) // creates a Font object

The previous example omits the Packages keyword and uses the java synonym because the Font class is in the java package.

Example 2. In the following example, the JavaClass object java.lang.String is passed as an argument to the newInstance method which creates an array:

var cars = java.lang.reflect.Array.newInstance(java.lang.String, 15)


See also
JavaArray, JavaObject, JavaPackage, Packages


Previous     Contents     Index     Next     
Copyright © 2000 Netscape Communications Corp. All rights reserved.

Last Updated September 28, 2000

TH |  TH2 |  TH3 |  TH4 |  TH5 |  TH6 |  TH7 |  TH8 |  TH9
Javajerka Carcasherdotcom-Seocontest  | Javajerka Contest 1  | Contest 2
TH Carcasherdotcom  |  Jerkasmarknad-Carcasherdotcom-Seocontest-html  | Contest
carcasherdotcomseocontest.jerkasmarknad.com  | carcasherdotcom-seocontest.jerkasmarknad.com
  carcasherdotcom seocontest  | carcasherdotcom-seocontest  | carcasherdotcom_seocontest  | MSN Carcasherdotcom Seocontest
  index jerkasmarknad  | javajerka  | jerspa  | jerka1950  | cultur25  | sweden  | submitforce  | hurricane  | nostalgipalatset  | smarterlinks  | violin.htm
  jerkasmarknad  | links  | MSN Jerkasmarknad  | jerkasmarknad/links  | jerkasmarknad/jerkasmarknad  | MSN Jerka2006  | jerka2006/jerkasmarknad
  jerka2006/kultursidan  | jerka2006/cultur25  | jerka2006/links  | search  | submitforce  | contactform  | sculpture  | watercolour  | acryl  | oilpicture  | photo
  teaterdekor  | parkteatern (intern)  | violin  | violoncell  | woodbottle  | deadheads  | home news  | seavirgin  | djurgarden  | submitforce  | vildblomma
  photography  | portal  | blog  | cncat links  | news online  | market  | submitforce  | radio  | violin jm  | view source  | vildblomma Index  | art
  javascript jerkasmarknad  | javascript javajerka  | javascript jerka1950  | javascript cultur25  | javascript jerspa  | toys  | serial  | sitemap
  ingmar bergman  | kista tower  | deadheads  | leksaker  | smarterlinks  | wood  | jerka  | sweden  | info  | violin 2  | contact form

Copyright 2006 Jerkasmarknad. All rights reserved. This material may not be published broadcast, rewritten, or redistributed.