Default
Description
This is a CGI based application which allows you to convert HTML forms
into java applet or application. Given input HTML file it generates java1.1
source code as the output. Most of the GUI elements are supported. It generates
all the initialisation code for you. It uses very flexible java.awt.GridBagLayout,
which you can customise to achieve required results. You can compile and
run generated stubs without writing a single line of java code.
To use it
-
Create HTML form
There are few rules to follow when creating form.
-
All components and text should be placed in the table.
-
Each cell of the table should contain only one input element or text, only
first one will be used, others will be ignored silently. Exceptions are
checkboxes and radios, you can place text after these elements, and it
will be treated as label for the Checkbox.
-
If you choose to name elements of the form (it is not compulsory), try
to avoid following default names for awt components: button, label,
text, text_area, list, choice, check, check_group, panel, container, c,
font, color. These names are used to create components for which no
name was specified, and they may conflict with the names you choose, the
program does not attempt to resolve such conflicts. In any case these names
aren't very descriptive, and you won't want to use them anyway.
-
Save your form to the file or paste it in to the textarea
If you prefer to paste the code, rather then uploading file, do not
forget to check the checkbox just above the textarea.
-
Type in the Class name
If class name is supplied the generated code will be a complete java
class which can be compiled, and probably run if you choose a super class
for it. If the name for the class is not specified, you'll get piece of
code which can be pasted in other class.
-
Select super class
Currently you can choose between Applet and Frame. Panel and Dialog
coming soon. Selecting the super class makes your class a subclass of a
particular class. Also some additional code is generated to allow simple
testing of the class, basically script generates main function,
which opens a window with the form inside it.
-
Choose Parsing Options
There are few of those. Normally you'll be happy with defaults, but
sometimes defaults just don't work.
The most important one is wether to close tags implicitly. I'm not
the author of the HTML parser which I used in this script, and do not quite
understand how the parsing is done. I have experienced some problems, when
converting html files generated in Word97. The HTML tree generated by parser
appeared to be broken due to paragraphs, outside and inside of the table,
and the problem seemed to go away when the implicit tag closure was turned
off. But if you do this, make sure that each tag has corresponding closing
tag, except for those which do not suppose to have closing tags at all.
The other one is wether to remove non-breaking spaces ,
they are quite annoying features which some html builders use very often,
even where you don't want them. You can ask the script to remove those.
Otherwise they appear as strange characters in the code, but the code still
compiles and runs fine, at least on my machine.
-
Press Convert, wait for result, save it to the appropriate
file, compile, run
Features
-
Text formatting:
-
bold
-
italic
-
monospaced
-
font face
-
font size
-
font color
-
Supported Components
Most of the HTML form tags are supported, for the exception of the
file upload and range elements, for which there are no equivalent classes
in standard java distribution.
Namely following input tags are supported:
| HTML Tag |
Corresponding Java Class |
| <input type="text"> |
TextField |
| <input type="password"> |
TextField with setEchoChar('*') |
| <input type="button|submit|reset"> |
Button |
| <input type="checkbox"> |
Checkbox |
| <input type="radio"> |
Checkbox with CheckboxGroup |
| <textarea> |
TextArea |
| <select size="1"> |
Choice |
| <select size=">1" multiple> |
List optionally multiselect |
-
Extended Color Support
You can specify background or foreground colour as
-
Standard html colours #RRGGBB, where R, G and B are hex digits representing
colour intensities of red, green and blue respectively.
-
SystemColor.systemcolorname very useful, when you want the application
to look like other applications on the system. See java documentation for
more info on SystemColor class and how to use it. The main advantage of
using these colours is that your program will look like any other application
on any machine, with any palette or scheme.
-
One of the predefined java colours: red, yellow, green, black ...
Examples
This html file was used as input, and
the following applet was generated. I
did not add single line of code.
Source Code
The source code is available to
those who need it. If you do any modifications which you think can be usefull
to other people, I'll be happy to see them.
Acknowledgments
First of all big thanks to ProHosting
which provides absolutely free hosting with full CGI support, this is the
best hosting I have ever used so far, and I used quite a few.
Many thanks to all those folks who have developed PERL,
which makes complex things easy (and is absolutely free),and specially
to Gisle Aas who have developed HTML parser,
which was used in this script, very extensively.
See Also: Java SOCKS Proxy
