Fast Answers to Frequently-Asked Questions

GENERAL COMPUTING

SOFTWARE DEVELOPMENT USING JAVA


GENERAL COMPUTING

Question 1 : How do I get a GLUE computer account?

Answer : All Students in ENCEi 489C/ENME 489C will be expected to have a
         GLUE computer account. 

         ------------------------------------------------------------------

         You can apply for one through the website

             http://www.helpdesk.umd.edu/faqs/unix

         ------------------------------------------------------------------


Question 2 : How do I activate a GLUE printing account?

    The Glue system operates under a "Pay-for-Print" policy.

    To print from a open glue lab, you will need a print account. This 
    account can be used not only for the Glue Open labs, but also all over 
    campus (WAM labs: PG2, Hornbake...). 

    Each page costs $0.10. Users must obtain a Terrapin Express card in
    Room 1109 South Campus Dining Hall, in the hours 08:00 - 16:00.
    After doing this, they must get their print account activated in the
    Laser Print Cost Recovery (LPCR) office, Room 3326 Computer Science
    Center. The minimum deposit for the Terrapin Express Account is $25. 

    Users can check their print account by telnetting to the address: 

          bank.umd.edu 

    The login id is "teller". The bank will then ask for the print account 
    number and the password. The user can then move funds from the Terrapin 
    Express account to the print account. 

    For further help, please consult the first-aider on duty.


Question 3 : How can I dial into the University computers from Home ?

Answer : Dial-up access to the College of Engineering's network of UNIX
         computers is provided through the Computer Science Center's (CSC)
         annex service. All dialup lines are set for 8 bits, 1 stop bit,
         and no parity.

         The modem pools that you can access are:

            (a)  (301) 209-0700  -- X2 56kbps modems, 3hr session limit.
                                    40 hrs per 14 days quota limit.

            (b)  (301) 864-2087  -- 33 kbps modems.
                                    15 min express service session limit.
                                    40 hrs per 14 days quota limit.

         Access from Baltimore

            (c)  (410) 962-8865  -- 28.8 kbps modems, 3hr session limit.
            (d)  (410) 962-8867  -- 28.8 kbps modems, 15 min express
                                    session limit.

         WAM (Workstation at Maryland) accounts are available to all
         University of Maryland students from the Computer Science Center
         Consulting Lab (CSS 1400). Bring your University ID and current
         registration card.

         To dial in, you will need to connect to the computer or terminal
         you are using. Run your favorite communications program and set
         your communications port parameters to 8 bits, 1 stop bit, and
         no parity.  vt100 is a good choice for the terminal type if you
         are not sure what to use.

         When the connection to the annex service is established, you will
         see the annex prompt. Issue the following command to initiate a
         login session:

               telnet <machine>.eng.umd.edu

         where <machine> should be replaced by the name of the workstation 
         that you would like to log into.


Question 4 : What WWW browsers are available at UMCP?

Answer : The glue system currently supports Netscape 4.7 and the UNIX
         version of Microsoft IE 5. 


Question 5 : I want to save a WWW page. What's the difference between txt, html and postcript ?

Answer : To save a file, click on the "File" item located in the top
         left-hand corner of the Netscape Browser.

         Then select the pull-down menu item that has a title

             "Save As..."

         A small window should pop-up requesting information on the
         location and format for the file containing the saved page.
         The three file formats are:

         Text       -- Save the the text within the page.

         Source     -- Save the html code for the page, including the text,
                       tags etc..

         Postscript -- This saves the file in Postscript format.
                       Postscript is a special computer language understood
                       by many printers, and is used to send text and graphics
                       of all varieties to the printer.  You can use this
                       option to save an image of a web page as a Postscript
                       file, which can then be sent to a Postscript printer to
                       reproduce the file on paper. 


Question 6 : How do I send a WWW page to the printer?

Answer : The answer to this question will depend on the local configuration
         of your computer. Generally speaking you will need to give a command
         like

              qpr -q name-of-printer name-of-postscript-file.ps

         See the lab attendant for specific details.


Question 7 : How do I compile and run a small C program?

Answer : Chapter 3 of Austin/Chancogne contains step-by-step instructions
         for compiling small C programs using the Gnu C compiler.
         Pay particular attention to command line arguments needed to
         set the filename for the program executable, and to link the
         program object code to the math library. 


Question 8 : Where should I put my home page?

Answer : When you log into your Glue account, you are initially
         in your home directory.  Typing:

           cd ../pub

         put you in your public directory.  This is a
         directory that the general public has access to, and
         therefore this is where your home page should be stored.

         You should put your home page in a file

            Welcome.html
         
         located inside the pub directory. So if your login
         name is let's say "dubya", then the location of your
         home page will be something like

            /afs/ ... /dubya/pub/Welcome.html

         (The row of dots indicates that the file system will change from
         machine to machine) Folks from outside the University of Maryland
         will be able to view your home page using the URL

            http://www.glue.umd.edu/~dubya/

         More Information : Follow the link to "Instructions for
         Creating a Personal Home Page" from the Internet Resources
         section of the ENCE 489C home page.


Question 9 : How can I get started with my Home Page?

Answer : You will need to write your Home Page in the Hypertext Markup
         Language (HTML). An easy-to-read introduction to HTML is

         "A Beginners Guide to HTML,"  

         located in section two of the Class Notes.


Question 10 : I'm on an IBM PC machine...how do I use the FTP program?

Answer : The File Transfer Protocol (FTP) program works on the same
         concept as the file manager as in Windows 3.1.

         To transfer files:

      1. Save the file onto disk.  Hard or floppy.

      2. Click on the window icon FTP.  This icon is usually pink letters
         on a white background. This icon will open up the "File Transfer
         Protocol" program.

      3. Click on the space that says profile name.  You will want to be
         able to get into glue with your login and password.
         One of the set ups in the drop list will allow you to do this.

      4. Fill in your login where it says user id and password where it
         asks.

      5. Click on OK

      6. You will now see a split window.  on the left hand side is the
         computer you are on, and on the right is your computer account.
         In order for you to put stuff(files, etc.) into your pub account
         you have to open up that part of your account.  Look at the right
         part of the screen.  In the upper right you will see something
         that looks like   ..  Click on the two dots.  This will take you
         up a level in your account.

      7. Now you should see another list of things. One should be pub.
         This is you pub account. Click on pub.  If you have started your
         web site you should at least see Welcome.html here.
         You are now in the pub part ofyour account.

      8. To transfer things there you now must look at the upper left of
         the window.

         Here you will see things that resemble the computer you are on.
         For instance [-a-], [-c-], are both drives.  [-a-] is your floppy
         drive and [-c-] is your hard drive.  If you have things saved on a
         floppy click on [-a-] and then you will see all the files that are
         on your disk.

      9. Now highlight the thing you want to transfer by clicking on it.

     10. Now that it is highlighted click on the right arrow and the
         program will transfer that file to your school account.

     11. Your done.  The file should now be on the right side bottom.  If it
         is there, then it is in your pub account.


Question 11 : Where can I find a selection of background patterns?

Answer : A good starting point is:

         http://home.netscape.com/assist/net_sites/bg/backgrounds.html

         For more sites, go to a search engine and do a search on
         "background pattern"


Question 12 : How can I download a background pattern from someone's page?

  • Answer : If you are running netscape on a PC, then you can simply move the
             cursor to the background, and click on the right button. A small
             window will appear asking where you want the background image to
             be saved.
    
             Otherwise, you can retrieve a background color pattern directly
             from the Netscape cache (the cache stores images and patterns
             locally on your computer, thereby enhancing performance).
    
             The cache can be accessed by typing
    
             about:cache
    
             in the "Location" window of Netscape.
    


    Question 13 : How can I put a counter on my home page?

    Answer : Free counters are available at:
    
             http://counters.qpt.com/
    
    


    Question 14 : I can't send E-mail from my Netscape Browser. What's the problem?

    Answer : First, check your html code to make sure you haven't made a
             silly typo. The html should look something like:
    
             E-mail : <a href="mailto:your-login-name@glue.umd.edu"><b>
                                      your-login-name@glue.umd.edu </b></a>
    
             If your E-mail still doesn't work then perhaps
             your Netscape browser settings are incorrect.
    
             To check your mail preferences go to the Netscape Options
             menu and button on "Mail and News Preferences". Then select
             the services page. The SMTP (simple main transfer protocol)
             setting for outgoing mail should be
    
                 smtp.glue.umd.edu
    
             for glue users, and 
             
                 smtp.isr.umd.edu
    
             for users at ISR.
    


    Question 15 : How do I get a domain name for my new company?

    Answer : You can register a domain name for your company by contacting
             Network Solutions Inc. See
    
                  www.internic.net.
    
             I believe the fee is $100/yr.
    
             Nothing happens physically? All this means is that some nameserver
             in the Internet world will contain an entry for your domain and
             point it to some IP address. If there is a machine on the Internet
             with that IP address, then all packets will be forwarded there.
             Otherwise, nothing will happen.
    
             Do I need to purchase a server and have it on for 24 hours/day?
    
             No. There are several companies out there that can house your
             domain for you for a fee. However, you are free to do so if you
             wish. 
    
             For more information, see the internic web site
    
             www.internic.net
    
             and the FAQ at
    
             http://rs.internic.net/domain-info/registration-FAQ.html
    


    Question 16 : What is a script file? How do I create one?

    Answer : A script file contains a copy of all of the commands
             given at the keyboard and all of the output sent to 
             the computer screen.
    
             The syntax for starting a script file is:
    
                 prompt >> script name-of-script-file
    
                 ..... now go ahead and run your programs. A copy
                       of the commands and program output will be
                       echoed to file "name-of-script-file"
             
             The script file is terminated by typing
    
                 prompt >> exit
    
             Now send the "name-of-script-file" file to the printer.
    


    Question 17 : What colors can I use English names for in HTML?

    Answer: FOR NEWER BROWSERS ONLY

    NameRGB CodeSampleNameRGB CodeSampleNameRGB CodeSample
    AliceBlue#F0F8FF AntiqueWhite#FAEBD7 Aqua#00FFFF
    Aquamarine#7FFFD4 Azure#F0FFFF Beige#F5F5DC
    Bisque#FFE4C4 Black#000000 BlanchedAlmond#FFEBCD
    Blue#0000FF BlueViolet#8A2BE2 Brown#A52A2A
    Burlywood#DEB887 CadetBlue#5F9EA0 Chartreuse#7FFF00
    Chocolate#D2691E Coral#FF7F50 CornflowerBlue#6495ED
    Cornsilk#FFF8DC Crimson#DC143C Cyan#00FFFF
    DarkBlue#00008B DarkCyan#008B8B DarkGoldenrod#B8860B
    DarkGray#A9A9A9 DarkGreen#006400 DarkKhaki#BDB76B
    DarkMagenta#8B008B DarkOliveGreen#556B2F DarkOrange#FF8C00
    DarkOrchid#9932CC DarkRed#8B0000 DarkSalmon#E9967A
    DarkSeaGreen#8FBC8F DarkSlateBlue#483D8B DarkSlateGray#2F4F4F
    DarkTurquoise#00CED1 DarkViolet#9400D3 DeepPink#FF1493
    DeepSkyBlue#00BFFF DimGray#696969 DodgerBlue#1E90FF
    FireBrick#B22222 FloralWhite#FFFAF0 ForestGreen#228B22
    Fuchsia#FF00FF Gainsboro#DCDCDC GhostWhite#F8F8FF
    Gold#FFD700 Goldenrod#DAA520 Gray#808080
    Green#008000 GreenYellow#ADFF2F Honeydew#F0FFF0
    HotPink#FF69B4 IndianRed#CD5C5C Indigo#4B0082
    Ivory#FFFFF0 Khaki#F0E68C Lavender#E6E6FA
    LavenderBlush#FFF0F5 LawnGreen#7CFC00 LemonChiffon#FFFACD
    LightBlue#ADD8E6 LightCoral#F08080 LightCyan#E0FFFF
    LightGoldenrodYellow#FAFAD2 LightGreen#90EE90 LightGrey#D3D3D3
    LightPink#FFB6C1 LightSalmon#FFA07A LightSeaGreen#20B2AA
    LightSkyBlue#87CEFA LightSlateGray#778899 LightSteelBlue#B0C4DE
    LightYellow#FFFFE0 Lime#00FF00 LimeGreen#32CD32
    Linen#FAF0E6 Magenta#FF00FF Maroon#800000
    MediumAquamarine#66CDAA MediumBlue#0000CD MediumOrchid#BA55D3
    MediumPurple#9370DB MediumSeaGreen#3CB371 MediumSlateBlue#7B68EE
    MediumSpringGreen#00FA9A MediumTurquoise#48D1CC MediumVioletRed#C71585
    MidnightBlue#191970 MintCream#F5FFFA MistyRose#FFE4E1
    Moccasin#FFE4B5 NavajoWhite#FFDEAD Navy#000080
    OldLace#FDF5E6 Olive#808000 OliveDrab#6B8E23
    Orange#FFA500 OrangeRed#FF4500 Orchid#DA70D6
    PaleGoldenrod#EEE8AA PaleGreen#98FB98 PaleTurquoise#AFEEEE
    PaleVioletRed#DB7093 PapayaWhip#FFEFD5 PeachPuff#FFDAB9
    Peru#CD853F Pink#FFC0CB Plum#DDA0DD
    PowderBlue#B0E0E6 Purple#800080 Red#FF0000
    RosyBrownBC8F8FF RoyalBlue#4169E1 SaddleBrown#8B4513
    Salmon#FA8072 SandyBrown#F4A460 SeaGreen#2E8B57
    Seashell#FFF5EE Sienna#A0522D Silver#C0C0C0
    SkyBlue#87CEEB SlateBlue#6A5ACD SlateGray#708090
    Snow#FFFAFA SpringGreen#00FF7F SteelBlue#4682B4
    Tan#D2B48C Teal#008080 Thistle#D8BFD8
    Tomato#FF6347 Turquoise#40E0D0 Violet#EE82EE
    Wheat#F5DEB3 White#FFFFFF WhiteSmoke#F5F5F5
    Yellow#FFFF00 YellowGreen#9ACD32


    Question 18 : From where can I download NetTerm?

    Answer : Try ......
    
             http://www.netterm.com/html/downloads.html
    


    Question 19 : How do I make acrobat pdf files?

    Answer: The isr has a daemon running that automtically makes pdf
            files. To use it, you log into an isr machine, and ftp the
            postscript file that you wish to convert to your account.
            Then copy the file to the directory
    
             /software/isrwww/html/misc/tools/acrobat/IN
    
             Wait for a few minutes, and the postscript file that you
             copied should appear along with a pdf file in the directory
    
             /software/isrwww/html/misc/tools/acrobat/OUT
    
             Move the pdf file and the postscript file out of the OUT
             directory to the place in your own homespace where you want
             to put them.
    


    Question 20 : What info do I need to access WebCT?

        The Web Courses Tool (WebCT) at Maryland operates as a secure
        web server. The web address is:
    
            https://www.courses.umd.edu/
    
        Students use their SID number and their MARS logon password
        to get onto the page.
    


    SOFTWARE DEVELOPMENT USING JAVA

    Question 1 : What are some of the key differences between C and Java?

        No preprocessor  -- Java does not include a preprocessor
        and does not define any analog of C's #define, #include, and so
        forth.  Program constants are replaced with
    
           static final data_type = data_value;
    
        for example,
    
           static final double dPi = 3.1415926;
    
        No global variables  -- Java defines a very clean namespace.
        Packages contain classes, classes contain fields and methods, and
        methods contain local variables.
    
        Well-defined primitive type sizes  -- Unlike C, all of
        the primitive datatypes in Java have well-defined sizes.
    
        No pointers  -- Java classes and arrays are reference types
        and references to objects and arrays are akin to pointers in C.
        However, in Java there is no address operator or mechanism to
        increment or decrement a pointer (i.e., do pointer arithmetic).
    
        Garbage collection  -- The Java virtual machine performs
        garbage collmection so that Java programmers do not have to
        explicitly manage (e.g., release memory to the operating systems)
        memory used by all objects and arrays.
    
        Method overloading  -- Java programmers can define multiple
        methods with the same name, so long as the methods have different
        parameter lists.
    
        Variable declarations anywhere  -- C requires local variable
        declarations to be made at the beginning of a method or block.
        Java allows them anywhere in the method or block.
    
        For more information, see the Nutshell book (2000).
    


    Question 2 : How has Java changed from versions 1.0 through 1.3?

    Answer : During the past five years (1996-2001) four versions of
             Java have been released. The key features in each release
             are as follows:
    
             Java 1.0  -- The first public release of Java contained 212
             classes organized into 8 packages.
    
             Java 1.1  -- The second release doubled the size of the Java
             platform to 504 classes organized into 23 packages.
    
             This release introduced the delegation event handling model
             and inner classes, leading to significant improvements in
             performance of the Java virtual machine.
    
             Java 1.2  -- The third release tripled the size of Java to
             1520 classes organized into 59 packages.
    
             This release is also called the Java 2 Platform.
    
             Java 1.3  -- Minor updates to Java 1.2 release (e.g., includes
             support for Java Sound as part of the Java Platform).
    
             This release is also called the Java 2 Platform, version 1.3.
    


    Question 3 : What editions of Java exist?

    Answer : SUN is working to create different versions of the Java platform
             for different uses. In this class we will use:
    
             -- The Standard Edition (details shown in previous question).
    
             Several versions are in development:
    
             -- Java 2 Enterprise Edition (J2EE) for Enterprise developers of
                the Java Platform.
    
             -- Micro Edition for consumer electronics, handheld PDAs and 
                cellular telephones.
    


    Question 4 : How do I access the Java 1.1 and Java 1.2 compilers?

    Answer : To access the Java 1.1 compiler on the Glue system type
    
             >> tap oldjava
    
             To access the Java 1.2 compiler type
    
             >> tap java
    
             Access to Java 1.0 is no longer provided. 
    
             Java 1.3 has been installed in the PCs in the Engineering
             labs. We hope that version 1.3 will also be installed on
             the glue system, Spring Semester 2001.
    


    Question 5 : How do I use the just-in-time compiler?

    Answer : One problem with Java bytecodes is their slow execution
             by Java virtual machines. A promising advance is just-in-
             time compilation, where Java bytecodes are converted 
             on-the-fly into native-platform machine code (see, for
             example, SUN's hotspot technology).
    
             Add details on compilation ....
    


    Question 6 : What is the Java Runtime Environment (JRE)?

    Answer : The Java Runtime Environment contains everything needed to run a
             Java program, but does not software needed to compile Java source
             code.
    
             One version of the JRE is implemented as a Java-plug in, designed
             to be connected to Netscape and Microsoft IE browsers.
    


    Question 7 : What are the basic data types supported in Java?

    The Java language has eight basic data types:

    Data Type Contains Default Size Range
    boolean true or false false 1 bit N.A.
    char Unicode character \u0000 16 bits \u0000 to \uFFFF
    byte Signed integer 0 8 bits -128 to 127
    short Signed integer 0 16 bits -32768 to 32757
    int Signed integer 0 32 bits -2147483648 to 2147483647
    long Signed integer 0 64 bits -9223372036854775808 to 9223372036854775807
    float IEEE 754 floating point 0.0 32 bits -1.4e-45 to 3.402e+38
    double IEEE 754 floating point 0.0 64 bits -4.9e-324 to 1.79e+308


    Question 8 : How do the keyword modifiers work in Java?

    Answer : Java uses keyword modifiers to adjust the scope and storage
             of program elements in much the same way as C.
    
             However, the details of implementation are quite different...
             as shown the the table.
    
    Modifier Applied to Meaning
    abstract class The class contains unimplemented methods and cannot be instantiated.
    interface All interfaces are abstract. This modifier is optional in interface declarations.
    method No body is provided in the method ... it is provided in the subclass instead. The signature is followed by a semicolon. The enclosing class must also be abstract.
    final class The class cannot be subclassed.
    method The method cannot be overriden (and is not subject to dynamic method lookup).
    field The field cannot have its value changed. In fact, static final fields are compile-time constants.
    variable A local variable, method parameter, or exception parameter cannot have its value changed.
    native method The method is implemented insome platform-dependent way (often in C). No body is provided, and the signiture is followed by a semicolon.
    name(package) class A non-public class is accessible only it its package.
    interface A non-public interface is accessible only it its package.
    member A member that is no private, protected or public has package visibility and is accessible only within its package.
    private member The member is accessible only withing the class that defines it.
    protected member The member is accessible only within the package in which it it defined and within the subclasses.
    public class The class is accessible anywhere the package is.
    interface The interface is accessible anywhere its package is.
    member The member is accessible anywhere its class is.
    static class An inner class declared static is a top-level class, not associated with a member of the containing class.
    method A static method is a class method. It is not passed an implicit this object reference. It can be invoked through the class name.
    field A static field is a class field. This is only one instance of the field, regardless of the number of class instances created. It can be accessed through the class name.
    initializer The initializer is run when the class is loaded, rather than when an instance is created.


    Question 9 : What is a Java package?

    Answer : A Java package is a named collection of classes (and possibly
             sub-packages.
    
             Packages allow for the grouping of related classes and the
             definition of a namespace for the classes they contain.
    


    Question 10 : What are the Java packages I will most likely use in this course?

    We will use packages associated with Java language, utilities and networking (e.g., downloading images/data over the web), the abstract windowing toolkit (AWT), and Swing.

    Java Language, Utilities and Networking

    Java Package Description
    java.applet Package of classes for running an applet.
    java.io This package contains classes and interfaces for program input and output (I.O), includine file I/O and streams of bytes and characters.
    java.lang This package contains classes for the core language, including System, String, Math, Thread and Exception.
    java.math This package contains classes for arbitrary precision integer and floating-point arithmetic.
    java.util Various utility classes including the collections framework for working with collections of objects.
    java.net This package contains a number of classes designed to facilitate networked computing.

    Abstract Window Toolkit (AWT)

    AWT Package Description
    java.awt Package of classes for the abstract windowing toolkit (AWT).
    java.awt.event Package of classes for the delegation event handling model employed within the AWT.

    Java Swing

    Swing Package Description
    javax.swing This highest-level package contains the basic Swing components, default component models, and interfaces delegate and model classes.
    javax.swing.border This package specifies the interfaces and classes that define and render specific border styles.
    javax.swing.event This package contains the Swing-specific event types and listeners. Swing components can also support events spcified in java.awt.event.
    javax.swing.plaf The plaf package contains the pluggable look-and-feel API used to define custom user interfaces. It includes libraries to emulate the look and feel of Windows, Macintosh, Motif and some custome interfaces created by SUN Microsystems.
    javax.swing.table The table package contains interfaces and classes that support Swing JTable control.
    javax.swing.tree The tree package contains interfaces and classes that support Swing JTree hierarchical tree class.

    To import all of the classes within a package into a Java program, simply append ".*" to the package name. For example, the applet classes can be imported with the statement:

        import java.applet.*;
    

    If you don't want to import all of the classes within a package, then simply name the classes you want in the import statement. For example, the statement:

        import java.net.URL;
    

    imports a set of classes (contained within java.net) that can represent a uniform resource locator (URL).


    Question 11 : What are the Java Foundation Classes (JFC)?

    Answer : The production version of the Java Development Kit 1.2 (also
             called Java 2) was released in December 1998. The JDK 1.2
             contains a sophisticated set of graphics and user interface
             application interfaces called the Java Foundation Classes (JFCs).
    


    Question 12 : What is the relationship between AWT, Swing and the JFCs?

    [JFC Diagram]

    Answer : The Java Foundation Classes contain five technologies:
    
             Accessibility API  -- Assistive technologies provide disabled
             people with additional assistance in using the user interface.
    
             Examples of assistive technologies include: speech recognition
             systems and screen magnifiers.
    
             Abstract Windowing Toolkit and Swing  -- The Abstract
             Windowing Toolkit (AWT) was launched with Java 1.0 and remains
             a key part of the JFC.
    
             When you write a user interface using Swing components, you still
             need to use the layout managers and event models supported by AWT.
    
             Java 2D Graphics API  -- The 2D Graphics API supports advanced
             2D Graphics and imaging.
    
             Drag and Drop  -- On native platforms supporting drag-and-drop
             (e.g., Windows 98), this technology provides drag-and-drop services
             between Java programs and native applications.
    
             Two of the key features of Swing are:
    
             Lightweight Components  -- Starting with the JDK 1.1, the AWT
             supports lightweight classes, meaning that the AWT classes do not depend
             on the classes of the underlying native system. Indeed, in Swing most
             of components have their own view supported by the Java look-and-feel
             classes.
     
             Pluggable Look-and-Feel  -- This feature enables a user to switch
             the look-and-feel of Swing components without restarting the application.
    
            For more information, see Pantham (1999).
    


    Question 13 : Why should I upgrade my Java graphics from AWT to Swing?

    Answer : The biggest difference between the AWT components and the Swing
             components is that the later are implemented with absolutely no
             native code. As a result, the Swing components are not restricted
             to the least common denominator (i.e., features common to every
             platform on which Java runs), and they can have more functionality
             than the AWT components.
    
             Examples of expanded functionality for the Swing components are
             as follows:
    
             1. New components for tables, trees, sliders, progress bars,
                internal frames and text components.
    
             2. Swing buttons and labels can display images instead of or in
                addition to text.
    
             3. Swing components don't have to be rectangular (e.g., Buttons
                can be round).
    
             4. You can easily add or change the borders drawn around most
                Swing components.
    
             5. The behavior or appearance of a Swing component can be easily
                changed by invoking methods on it or creating a subclass of it.
    
                For example, Swing components can have tooltips placed over
                them (a tooltip is a textual popup that momentarily appears
                when the mouse cursor rests inside the component's painting
                region).
    
             For more information on this topic, see Walrath (1999).
    


    Question 14 : Are the AWT and Swing components designed to work together?

    Answer : No.
    


    Question 15 : What is the model-view-controller (MVC) architecture?

    [MVC Model]

    Answer : The swing components are based on the model-view-controller (MVC)
             design. Components of the MVC models are as follows:
    
             Model  -- The model encompasses the state data for each
             component.
    
             View  -- The view refers to how each component will appear
             on the screen.
    
             Controller  -- The controller is the portion of the user
             interface that dictates how the components interact with events
             (e.g., keyboard events, mouse clicks). The controller in each 
             component knows what events require an action and which events
             can be ignored.
    
             Each element in the MVC model requires information from the other
             elements to function properly. For details, see the adjacent
             figure.
    


    Question 16 : How does the MVC architecture work in Swing?

    [MVC in Swing]

    Answer : The Swing components actually make use of a simplified variant
             of the MVC model called model-delegate. This design combines
             the view and controller objects into a single element that 
             draws the component to the screen and handles GUI events know
             as the user interface (UI) delegate.
    
             Bundling of the graphics capabilities and event handling in
             Swing components makes sense in Java because most of the event
             handling is taken care of by the AWT.
    
             A second purpose of the UI delegate is to react to various events
             that propagate through the component.
    


    Question 17 : What is a JAR file and how do I use them?

    Answer : A Java archive (JAR) file is a ZIP file that contains Java class
             files, auxiliary resource files required by those classes, and
             optional meta-information (e.g., a list of files contained within
             the JAR file).
    
             JAR files are created with jar, the Java archive tool.
    


    Question 18 : What is a JavaBean?

    Answer : The JavaBeans API provides a framework for defining reusable, embeddable,
             modular software components that can be manipulated visually in a 
             builder tool. Beans are characterized by the properties, events and
             methods they export.
    
             The most common use of beans is for graphical user interface components,
             such as those in the AWT and Swing packages. There are, however, no 
             limitations on bean complexity -- for example, embeddable spreadsheet
             applicaion programs have also been implemented as JavaBeans.
    
             For more information, see Flanagan (1999).
    


    Question 19 : How can I run an applet?

    Answer : The simplest way of running an applet is with the appletviewer.
    
             An appletviewer reads or downloads the one or more HTML documents
             specified by the filename or URL on the command line. Next, it
             downloads any applets specified in any of those files and runs
             each applet in a separate window. If the specified document or
             documents does not contain an applet, the appletviewer does nothing.
    
             In Java 1.1, the appletviewer recognizes applets specified with
             the <APPLET> tag. A simple implementation might look like:
    
                <html>
                <body>
    
                <applet code = "SimpleExample.class"
                        width = 200 height = 200
                </applet>
    
                </body>
                </html>
    
             Suppose that these markup tags are contained within a file
             called simple.html. To run the appletviwer, simply type:
    
             appletviewer simple.html
    
             This example assumes that SimpleExample.class file is located on
             the same machine as the appletviewer. The applet is displayed in
             a window having dimensions 200 by 200 pixels. More complicated
             implementations download the class file over the net and initialize
             the Java applet with parameter values...
    
             In Java 1.2 and 1.3, the appletviewer also recognizes applets specified
             with the <OBJECT> and <EMBED> tags. The java code page
             for this class contains numerous examples of these tags.
    


    REFERENCES

    1. Campione M., Walrath K. and Humi A., The Java Tutorial, Third Edition , A Short Course on the Basics, Addison-Wesley, 2001.
    2. Flanagan D., Java in a Nutshell 3rd Edition, O'Reilly, 1999.
    3. Gutz S., Up to Speed with Swing , Second Edition, Manning, Grenwich, 2000.
    4. Pantham S., Pure JFC Swing , SAMS Publishing, 1999.
    5. Walrath K. and Campione M., The JFC Swing Tutorial : A Guide to Constructing GUIs, Addison-Wesley, 1999.


    Developed in January 1997 by Mark Austin
    Copyright © 1997-2002, Department of Civil Engineering, University of Maryland