Microsoft KB Archive/168943

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.



INFO: Frequently Ask Questions for AFC

Last reviewed: July 29, 1998
Article ID: Q168943



The information in this article applies to:

  • Microsoft Win32 Virtual Machine for Java
  • Microsoft SDK for Java version 2.02

SUMMARY

This article covers some of the most Frequently Asked Questions (FAQ) about the Microsoft Application Foundation Classes, AFC.

For other Java related FAQs search the Web at http://support.microsoft.com/support for 'JAVA' and 'FAQ'.

MORE INFORMATION

Q. 1. How can I create a scrollable edit control in AFC?

A. In AFC all scrolling is performed using viewers. You can place an UIEdit control inside of a UIScrollViewer to get autoscrolling behavior. If you are placing the UIScrollViewer in a free-flowing layout manager, you should override the UIScrollViewer's getPreferredSize() and getMinimumSize() methods. If you are implementing a single line edit control, use the UIScroll.NOSHOW style and UIDrawText.setSingleLine() method.

Q. 2. How can I use an AWT control in my AFC program?

A. The UIAwtHost class enables AWT-based components to be used in AFC containers. For an example of how to host an AWT component, please see the SDK for Java 2.0x documentation for com.ms.ui.UIAwtHost and the AFC article titled "Introduction to AFC."

Q. 3. How can I use an AFC control in my AWT program?

A. The AwtUIHost class enables AFC-based components to be used in AWT containers. The constructor of AwtUIHost takes the IUIComponent to host in the AWT container. AFC also includes the AWT compatibility classes. For more information please see the SDK for Java 2.0x AFC article titled "Introduction to AFC."

Q. 4. How can I convert my AWT application into an AFC application?

A. The SDK for Java 2.0x includes a tool called AWT2AFC. This tool parses Java source code and determines what changes are necessary to convert the source to use the Application Foundation Classes (AFC).

Q. 5. How can script in my HTML page call into an AFC applet?

A. When writing an AFC applet, you must derive a class from AwtUIApplet and also from UIApplet. Your scripting code only has access to your AwtUIApplet derived class. Please see the SDK for Java 2.0x AFC article titled "Introduction to AFC" for an example of how to allow scripting code access to your UIApplet derived class. This is demonstrated in the AFCSkeleton section, where the getInfo() method is exposed.

Q. 6. Why does my paint() method never gets called in my UICanvas derived class?

A. In AFC the paint method takes com.ms.fx.FxGraphics as a parameter, not java.awt.Graphics. If you write a paint method that takes a java.awt.Graphics object your program will compile, but this method will never get called. The proper function signature is "public void paint(FxGraphics g)". For more information see the SDK for Java 2.0x documentation for com.ms.ui.UIComponent.

Q. 7. If I am targeting AFC102.ZIP, can I still use the 1.1 event delegation model?

A. You can use the JDK 1.1 event model in AFC 1.02, provided you remain within AFC. The com.ms.ui.event.* package has been implemented in JDK 1.02- compatible AFC. This implementation relies on the VM firing events, so a JDK1.02 event must exist for it to be implemented in an AFC listener.

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:

   http://support.microsoft.com/support/visualj/
   http://support.microsoft.com/support/java/

(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Rafael M. Munoz, Microsoft Corporation

Keywords          : kbusage AWTPkg JVM kbfaq
Technology        : kbInetDev
Platform          : WINDOWS
Issue type        : kbinfo



================================================================================



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 29, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.