11Notes
22=====
3- updated 9/15/19 -- adds integer 1/0 == 0
3+ updated 1/4/19 -- nio
4+ updated 9/15/18 -- adds integer 1/0 == 0
45updated 7/24/18 -- most classes replaced with https://github.com/frohoff/jdk8u-jdk
56updated 6/28/18 -- arrays do not inherit Object
67updated 2/26/18
@@ -21,7 +22,7 @@ implemented using older source code, and there are some missing methods.
2122DESIGN PHILOSOPHY
2223=================
2324
24- The SwingJS design goal is to recreate a recognizable, easily debuggable
25+ The java2script/ SwingJS design goal is to recreate a recognizable, easily debuggable
2526equivalent in JavaScript for as much of Java as practical. This means, for example,
2627that one can call in JavaScript
2728
@@ -49,8 +50,8 @@ Obviously, there are limitations. One is performance, but we have seen reproduci
4950performance at 1/6 - 1/3 the speed of Java. Achieving this performance may require
5051some refactoring of the Java to make it more efficient in both Java and JavaScript.
5152"for" loops need to be more carefully crafted; use of "new" and "instanceof" need to be
52- minimized in critical areas; overloaded methods (methods with the same name but different
53- signatures) should be renamed .
53+ minimized in critical areas. Note that method overloading -- that is, the same method name
54+ with different parameters, such as read(int) and read(byte) -- is no longer any problem .
5455
5556
5657Threads
@@ -74,35 +75,6 @@ return PropertyChangeEvents to signal that they have been disposed of and contai
7475More on this later....
7576
7677
77-
78- No Non-Swing AWT Components
79- ---------------------------
80-
81- Swing was introduced into Java well after the Java Abstract Window Toolkit (AWT) was well
82- established. As such, its designers chose to allow AWT controls such as Button and List to be used
83- alongside their Swing counterparts JButton and JList. Reading the code, it is clear that this
84- design choice posed a huge headache for Swing class developers.
85-
86- For SwingJS, we decided from the beginning NOT to allow this mixed-mode programming and
87- instead to require that all components be Swing components. However...
88-
89- The a2s Adapter Package
90- -----------------------
91-
92- ...originally, we thought that we would restrict ourselves to JApplets only. That is, only
93- Swing-based applets. But as we worked, we discovered that there are a lot of great
94- applets out there that are pre-Swing pure-AWT java.applet.Applet applets. Our problem was
95- that we also wanted it to be possible to quickly adapt these applets to JavaScript as well.
96-
97- The solution turned out to be simple: Write a package (a2s) that recreates the interface for
98- non-Swing components as subclasses of Swing components. Thus, a2s.Button subclasses javax.swing.JButton
99- but also accepts all of the methods of java.awt.Button. It's not perfect, and the ultimate
100- solution is probably to just change java.awt.Xxxx itself to subclass javax.swing.JXxxx.
101- In any case, it works -- mostly. By adding the a2s package to a project and changing the include
102- statements to target a2s instead of java.awt, non-Swing applets can be easily converted to JavaScript.
103- Certainly there will be issues such as missing methods. It is all a work in progress.
104-
105-
10678Native calls
10779------------
10880
@@ -119,7 +91,9 @@ Swing GUI Peers and UIClasses
11991
12092One of the biggest adaptations introduced in SwingJS is in the area of the graphical
12193user interface. The issue here is complex but workable. In Java there are two background
122- concepts -- the Component "peer" (one per component) and the Component "uiClass" (one per class).
94+ concepts -- the Component "peer" (one per "heavy-weight" component, such as a Frame) and the
95+ component "uiClass" (one per component, such as JButton or JTextField).
96+
12397Peers are native objects of the operating system. These are the virtual buttons and text areas
12498that the user is interacting with at a very base level. Their events are being passed on to
12599Java or the browser by the operating system. UI classes provide a consistent "look and feel"
@@ -139,7 +113,7 @@ more adaptable, this approach allows far more versatility to SwingJS developers,
139113to modify the GUI to suit their needs if desired.
140114
141115In SwingJS, since we have no access to native peers except through the browser DOM,
142- it seemed logical to merge the peer and UI idea. So instead of having one peer per control and
116+ it seemed logical to merge the peer and UI idea. So instead of having one peer per heavy-weight control and
143117one UI class instance for each control type, we just have one UI class instance per control, and
144118that UI class instance is what is being referred to when a "peer" is notified.
145119
@@ -154,6 +128,40 @@ The origin of most issues (read "bugs") in relation to the GUI will probably be
154128swingjs.plaf JSxxxxUI.java code.
155129
156130
131+ Swing-only Components -- no longer an issue
132+ -------------------------------------------
133+
134+ Swing was introduced into Java well after the Java Abstract Window Toolkit (AWT) was well
135+ established. As such, its designers chose to allow AWT controls such as Button and List to be used
136+ alongside their Swing counterparts JButton and JList. Reading the code, it is clear that this
137+ design choice posed a huge headache for Swing class developers.
138+
139+ For SwingJS, we decided from the beginning NOT to allow this mixed-mode programming and
140+ instead to require that all components be Swing components.
141+
142+ However, this is no longer an issue. All AWT components in SwingJS are now subclasses of
143+ javax.swing.JComponent. So far, we have found no problem with this.
144+
145+
146+ The a2s Adapter Package
147+ -----------------------
148+
149+ Originally, we thought that we would restrict ourselves to JApplets only. That is, only
150+ Swing-based applets. But as we worked, we discovered that there are a lot of great
151+ applets out there that are pre-Swing pure-AWT java.applet.Applet applets. Our problem was
152+ that we also wanted it to be possible to quickly adapt these applets to JavaScript as well.
153+
154+ The solution turned out to be simple: Write a package (a2s) that recreates the interface for
155+ non-Swing components as subclasses of Swing components. Thus, a2s.Button subclasses javax.swing.JButton
156+ but also accepts all of the methods of java.awt.Button. It's not perfect, and the ultimate
157+ solution is probably to just change java.awt.Xxxx itself to subclass javax.swing.JXxxx.
158+ In any case, it works -- mostly. By adding the a2s package to a project and changing the include
159+ statements to target a2s instead of java.awt, non-Swing applets can be easily converted to JavaScript.
160+ Certainly there will be issues such as missing methods. It is all a work in progress.
161+
162+ All AWT components now subclass a2s components, which in turn subclass JComponet.
163+
164+
157165
158166UNIMPLEMENTED CLASSES BY DESIGN
159167===============================
@@ -167,9 +175,11 @@ keyboard accelerators
167175TODO LIST FOR UNIMPLEMENTED CLASSES
168176===================================
169177
170- JEditorPane (minimal implementation)
171- JSplitPane (in development, BH)
172- JTabbedPane (in development, NEM)
178+ JEditorPane (minimal implementation) - DONE 12/2018
179+ JSplitPane - DONE 8/2018
180+ JTabbedPane - DONE 10/2018
181+
182+ JTree
173183
174184
175185MINOR ISSUES--required some rewriting/refactoring by Bob and Udo
@@ -234,6 +244,12 @@ as it is used to key for AppContexts. We will see if that use useful or not.
234244PROGRESS
235245========
236246
247+ 1/4/2019
248+
249+ Over the course of 7/2018 - 12/2018 there have been many updates to Java2Script/SwingJS.
250+
251+
252+
2372536/28/2018
238254
239255Major bug fixing session in Dundee, Scotland, is finding subtle issues and some missing
0 commit comments