Skip to content

Commit e399cd9

Browse files
hansonrhansonr
authored andcommitted
swingjs/a2s/_README.txt
The swingjs/a2s/* AWT/Swingjs adapter classes were moved from a2s/* on 10/23/2018. The swingjs/a2s package provides a method of using non-Swing AWT components (Button, TextField, etc.) even though SwingJS requires Swing components (JButton, JTextField, etc.). This is necessary because SwingJS does not implement "mixed-mode" containers -- JPanels that have AWT Buttons, for example. This possibility was clearly a nightmare for Swing developers, and the code backing this capability was just way too complex to even consider converting. There is probably a reason this was never done before, but I have not discovered it yet. That is to say, this works. The intent is to provide a means of taking a project that is not a Swing application or does not fully use Swing components and make it work in SwingJS with no special handling. In Java, a reference to "java.awt.Button" is just that. In JavaScript, that call is to a javax.swing.JButton via the intermediary swingjs.a2s.Button. It is still recommended to convert a non-Swing application or applet prior to working with SwingJS, because it is not guaranteed that this implementation is complete. But, that said, this does work. Older AWT mouse events are passed on to the component as before, even though they are also passed on by the listener mechanism introduced in Swing.
1 parent c1a13c8 commit e399cd9

File tree

1 file changed

+18
-14
lines changed
  • sources/net.sf.j2s.java.core/src/swingjs/a2s

1 file changed

+18
-14
lines changed
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
The a2s package has nothing to do with JavaScript.
1+
The swingjs/a2s/* AWT/Swingjs adapter classes were moved
2+
from a2s/* on 10/23/2018.
23

3-
It contains a set of minimal classes that behave like AWT
4-
components (Button, TextField, etc.) but actually subclass Swing
5-
components such as JButton and JTextField. This is necessary because
4+
The swingjs/a2s package provides a method of using non-Swing AWT
5+
components (Button, TextField, etc.) even though SwingJS requires
6+
Swing components (JButton, JTextField, etc.). This is necessary because
67
SwingJS does not implement "mixed-mode" containers -- JPanels that have
78
AWT Buttons, for example. This possibility was clearly a nightmare for
89
Swing developers, and the code backing this capability was just way too
910
complex to even consider converting.
1011

11-
There is probably a reason this was never done before.
12+
There is probably a reason this was never done before, but I have not
13+
discovered it yet. That is to say, this works.
1214

1315
The intent is to provide a means of taking a project that is not
1416
a Swing application or does not fully use Swing components and make it work
15-
in SwingJS by just tweaking its import statements.
17+
in SwingJS with no special handling. In Java, a reference to "java.awt.Button"
18+
is just that. In JavaScript, that call is to a javax.swing.JButton via
19+
the intermediary swingjs.a2s.Button.
1620

17-
However, in our experience, much can go wrong with this, and a much better
18-
plan is to convert a non-Swing application or applet.
21+
It is still recommended to convert a non-Swing application or applet prior to
22+
working with SwingJS, because it is not guaranteed that this implementation is
23+
complete.
1924

20-
These classes should be used with care. They are just very minimal implementations
21-
that attempt to reproduce the API of an AWT component as a Swing component.
25+
But, that said, this does work. Older AWT mouse events are passed on to the
26+
component as before, even though they are also passed on by the listener
27+
mechanism introduced in Swing.
2228

23-
24-
25-
26-
29+
Bob Hanson
30+
2018.10.23

0 commit comments

Comments
 (0)