Where can I find detailed information on how AWT interacts with the native OS?

I was looking for detailed information on the basics of the AWT package. In particular, how it interacts with the host operating system to create Windows and their contents.

Can someone point me to such documentation or provide any other information?

+7
source share
5 answers

OpenJDK source is the way to go. You just need to click the appropriate folder. You can see the internal code as follows:

checkbox = new AwtCheckbox(); ... checkbox->CreateHWnd(env, labelStr, style, exStyle, x, y, width, height, awtParent->GetHWnd(), reinterpret_cast<HMENU>(static_cast<INT_PTR>( awtParent->CreateControlID())), ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_BTNFACE), peer); 

CreateHWnd can be found in awt_Component.cpp, where it calls the CreateWindowEx .

+5
source

Basic:
Most C ++ GUI class libraries are platform specific, not only due to different hardware capabilities, but the subtle differences between the โ€œlook and feelโ€ of the various Windowing operating systems. The Java Abstract Window Toolkit provides a cross-platform library that aims to monitor the external concepts of various OS platforms.

  Toolkit ------------------------------------------------ AWT --------|--------- Button List JVM ------|-------------|-------------------------------------------------- Button Peer List Peer Native GUI (Windows, Mac, X) 

Additional Information on Java GUI Event Programming

AWT provides two levels of API:

  • A common interface between Java and the proprietary system used to manage windows, events, and layouts. This API is at the core of Java GUI programming and is also used by Swing and Java 2D. He contains:

    • The interface between the native windows system and the Java application;
    • The core of the GUI event subsystem;
    • Several layout managers;
    • An interface for inputting devices such as a mouse and keyboard;
      and
    • A java.awt.datatransfer package for use with the clipboard and drag and drop.
  • A basic set of GUI widgets such as buttons, text boxes, and menus.
    It also provides the AWT Native Interface , which allows you to convert libraries compiled into native code directly onto the AWT Canvas surface.

AWT also provides access to higher-level applications, for example:
Access to the system tray on supporting systems; and Ability to run some desktop applications, such as web browsers and email clients from a Java application.
To get the source code for the Native OpenJDK AWT classes, use the link below

jdk6 / jdk6-gate / jdk / src / windows / native / sun /
jdk6 / jdk6-gate / jdk / src / windows / native / sun / windows / (Windows-AWT-Native classes).

OpenJDK (GPL)

  • Sun announced in 2006 that Java would become open source.
  • The full source code for the Java class library under the GPL was released on May 8, 2007.
  • On October 11, 2010, IBM, by far the largest contributor to the Apache Harmony project, decided to join Oracle on the OpenJDK project, effectively shifting its efforts from Harmony to OpenJDK.
  • On January 11, 2011, the Mac OS X Port project was created in OpenJDK, and Apple made its first public contribution to the project. Apple's initial contribution based on the BSJ OpenJDK port ( OpenJDK โ„ข 6 Source Release ).

Link:

[ OpenJDK repositories .]

Open jdk6 / jdk6-gate / jdk / src / share / classes / java / awt / (AWT source code example)

OpenJDK core project based on JDK 7

You can find OpenJDK features here

Caciocavallo , a Project that provides an OpenJDK-based Java API to facilitate AWT implementation on new systems. The project successfully implemented AWT widgets using Java2D.
[OpenJDK mailing list .]

Read the AWT Documentation for a clear understanding of its implementations.

Fallow awt-dev Mailing Lists to attend.

+4
source

This is an implementation detail. The defacto standard will be how Oracle implemented it. If you really want to find out, look at the source code. It can be found at http://openjdk.java.net/ . Links are in the left column under the search box. The corresponding classes should be in the sun.awt package.

+2
source

There is a good pdf (mentioned below) .... but for me it is quite difficult to understand. But it may be useful for you.

How Java programs interact with virtual machines at the microarchitecture level.

+1
source

Awt does this using native methods. These are java methods that reference their own language in a separate file. Therefore, if you use windows and want to open a window, java will use C ++ to open the window.

http://en.wikipedia.org/wiki/Java_Native_Interface

http://en.wikipedia.org/wiki/Java_AWT_Native_Interface

-2
source

All Articles