RetroBASIC

Retrogamecoding(.org) => Other Languages => Topic started by: ScriptBasic on May 25, 2013, 04:47:17 PM

Title: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 04:47:17 PM
I don't know if you guys remember JAPI or not but I think it's a cool extension to any language now that Java is so popular on Android. It was abandoned it seems back in 2003 with the binaries compiled for AWT. After looking over the source, I noticed a Swing version of the Java code. I compiled the Swing version of the Java code building JAPI.jar and used that as the japiserver. Everything seems to work fine and I'm blown away how fast it is. I posted the ScriptBasic version of JAPI on the SB forum and I attached the japi.dll & japi.h (generic version) to this post. It would be interesting to see how this would work as a 2D game engine.

Title: Re: JAPI 2.0
Post by: Mopz on May 25, 2013, 05:46:47 PM
I think I'll have a look at this, thanks :) Should work fine as a naalaa extension.
Title: Re: JAPI 2.0
Post by: Mopz on May 25, 2013, 06:08:40 PM
Could you make a static library of it instead? I'll have to create a dll for the naalaa extension, and one dll looks better than two. I'm using MS VC2010.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 07:56:31 PM
The JAPI 2.0 japi.lib is attached.



Title: Re: JAPI 2.0
Post by: Cybermonkey on May 25, 2013, 08:43:43 PM
Don't we also need the JAPI.jar? Or did I miss anything?
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 08:55:31 PM
Quote
Don't we also need the JAPI.jar?

Nope.

It's embedded in the DLL/lib.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 09:04:03 PM
FYI

I registered JAPI2.com and plan a forum or blog to help bring this project back alive. At this point we have a ScriptBasic extension module, a C DLL (VC10) and a LIB (VC10) that seem to be working based on the test programs that came with the distribution. It would be nice to bring someone into the fold that has a Java background. I'm stumbling along the best I can with it. Maybe when the japi2.com site opens it's doors, more of an interest in an alternative Java programming paradigm might unfold.

Title: Re: JAPI 2.0
Post by: Cybermonkey on May 25, 2013, 09:13:28 PM
Quote
Don't we also need the JAPI.jar?

Nope.

It's embedded in the DLL/lib.

Ah, okay. I just tested the japi.pas from the original page with your extension. At least it works on Windows, but I think for Linux I have to do some work on the unit. Anyway, I have no SWING user interface. See attached screenshot. Although it should look like this, right?

(http://files.allbasic.info/ScriptBasic/japi_sbut.png)

Another annoying thing is that Windows always asks if the firewall should block the program or not ... Well, not always but once a program is compiled and started.
Title: Re: JAPI 2.0
Post by: Mopz on May 25, 2013, 09:20:57 PM
The JAPI 2.0 japi.lib is attached.

Thanks! Let's see what fun I can make out of it. I need more extensions before I can feel good about releasing another naalaa version, and this one'll be good :)
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 09:27:50 PM
The binaries from the old site are based on awt. The 2.0 series is based on swing. I used mingw32 to process the Makefile that compiles the Java code (javac) and builds the C compiled helper programs that generates the appropriate binding code. I then use MS VC10 to create the final DLL/LIB.

Title: Re: JAPI 2.0
Post by: Cybermonkey on May 25, 2013, 09:40:11 PM
The binaries from the old site are based on awt. The 2.0 series is based on swing. I used mingw32 to process the Makefile that compiles the Java code (javac) and builds the C compiled helper programs that generates the appropriate binding code. I then use MS VC10 to create the final DLL/LIB.
Erm, then you posted here the AWT version? Could you also post the SWING version?
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 25, 2013, 09:43:09 PM
Okay, I downloaded the SWING version from your forum, but now I have the problem that the procedure j_button isn't found in the DLL.
Title: Re: JAPI 2.0
Post by: Mopz on May 25, 2013, 09:48:38 PM
I did use java a lot for gui programs many years ago, always liked awt better than swing because of the native look. That's the good thing about iup too. People want your programs to look and feel the way they're used to. But I'll focus on the render speed for now, as that's my area of expertise.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 09:55:43 PM
Does the demos that came with the SBJAPI2_RC1.zip  run? (use the SB JAPI script code as an example)

Both Charles and I were able to use the generic japi.dll with the Mandelbrot example.



Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 09:59:49 PM
Quote
I did use java a lot for gui programs many years ago, always liked awt better than swing because of the native look.

AWT is ugly like Motif. I see no performance hit using swing. The UI that swing brings to the table is awesome and consistent across the board.

 
Title: Re: JAPI 2.0
Post by: Mopz on May 25, 2013, 10:15:39 PM
Quote
I did use java a lot for gui programs many years ago, always liked awt better than swing because of the native look.

AWT is ugly like Motif. I see no performance hit using swing. The UI that swing brings to the table is awesome and consistent across the board.

If I wanted beauty I'd stick to naalaa's SimpleWidget and create a sweet theme in GIMP.

(http://www.naalaa.com/temp/sw.jpg)
(http://www.naalaa.com/temp/win3.jpg)

But people don't want things that look different.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 10:20:19 PM
Quote
But people don't want things that look different.

True. Chris's EZGUI for PowerBASIC battles that issue all the time.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 25, 2013, 10:55:05 PM
Quote
I did use java a lot for gui programs many years ago,

Marcus,

It would be really helpful if you could compile the JAPI swing Java code and fix the deprecation warnings. I have this bad felling the Java folks made the decision to drop deprecated code support in 64 bit. JAPI swing does weird things or just errors running some of it's demos. If we can get a current swing jar built then adding functionality will be good across the board.

John
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 09:47:01 AM
Does the demos that came with the SBJAPI2_RC1.zip  run? (use the SB JAPI script code as an example)

Both Charles and I were able to use the generic japi.dll with the Mandelbrot example.
No, I am using Freepascal with the japi.pas header. The AWT version works after I changed the J_ to j_ in the header (seems to be case sensitive). Maybe I have to change that back? I tried the examples here: http://userpages.uni-koblenz.de/~evol/japi/examples/p-examples/
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 10:57:25 AM
Nope, doesn't work with Freepascal. Only the "older" AWT library does.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 26, 2013, 03:38:43 PM
I know nothing about Pascal so I wouldn't know where to start.

Does the JAPI.jar build and create the byte array include of it?
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 03:49:54 PM
I know nothing about Pascal so I wouldn't know where to start.

Does the JAPI.jar build and create the byte array include of it?
No, I use your pre-made DLL. The one which is attached in the first post does work. The one downloaded from scriptbasic.org does not work. I did'nt build anything myself.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 26, 2013, 04:50:30 PM
ScriptBasic extension modules (.dll) are not in standard DLL format and are specific to SB. I generated a generic version of the japi.dll that works fine with OxygenBasic (http://www.oxygenbasic.org/forum/index.php?topic=766.0) and DLLC (FFI for SB). I have attached a zip with the japi.dll and japi.h for you to give a try. (swing version) I thought Pascal had it's own special DLL interface. (VCL).

Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 05:18:01 PM
ScriptBasic extension modules (.dll) are not in standard DLL format and are specific to SB. I generated a generic version of the japi.dll that works fine with OxygenBasic (http://www.oxygenbasic.org/forum/index.php?topic=766.0) and DLLC (FFI for SB). I have attached a zip with the japi.dll and japi.h for you to give a try. (swing version) I thought Pascal had it's own special DLL interface as well.
Ah, thanks, I will try that later. And, no, Freepascal can use regular C/C++ DLLs (also Delphi so far as I know ...).
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 26, 2013, 05:43:42 PM
If you can use win32 DLLs with a cdecl calling format, you should be set to go and be able to run all your JAPI Pascal examples.
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 08:09:18 PM
ScriptBasic extension modules (.dll) are not in standard DLL format and are specific to SB. I generated a generic version of the japi.dll that works fine with OxygenBasic (http://www.oxygenbasic.org/forum/index.php?topic=766.0) and DLLC (FFI for SB). I have attached a zip with the japi.dll and japi.h for you to give a try. (swing version) I thought Pascal had it's own special DLL interface. (VCL).
But that's the same as in the first post. No SWING, just AWT ...  :(
Could you provide a cdecl format dll with SWING support?
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 26, 2013, 08:17:23 PM
The japi.dll I posted was built with the swing directory and works fine with ScriptBasic and OxygenBasic and anything else for that matter that can load a win32 DLL.

Can you post a screenshot of the choice.pas example? You should see a Windows like themed listbox with a Windows like scrollbar.

Can you try the ScriptBasic or O2 version and see what it looks like?

Does your screen look anything like the ones I posted on ScriptBasic for Windows?
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 08:56:32 PM
Okay, here's the screenshot. Both DLLs are exactly the same in size: 197 kb. The Scirba DLL was slightly larger (about 250 kb).
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 26, 2013, 09:12:14 PM
That's what its suppose to look like. It's working as a swing JAPI dll. The AWT version wouldn't show the Windows like drop down button.

Why do you think this is the AWT version? Try running the 2003 binary from the JAPI site and you will notice the difference.

P.S.

Making someone log in to see an attachment should be change to guset access. IMHO

Title: Re: JAPI 2.0
Post by: Cybermonkey on May 26, 2013, 09:24:54 PM
Because the buttons look flat like on Windows 95. With SWING the buttons IMHO are like in the above screenshot from your page (shrink button).
And because it is totally the same. I just downloaded the original DLL from japi.de and the choice.pas looks absolutely the same.
First screenshot is the SWING version, second the AWT version, so where is the difference?
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 03:23:46 AM
I recompiled the java directory which the build tools use as the default. You are right, the GUI still looks the same. I have done some compares between the 'java' directory and the 'swing' directory of .java programs and there is definitely indications that the 'swing' directory programs are using swing syntax replacing the 'awt' code that is still in the 'java' directory version.

Maybe Marcus can sort this out as I'm reaching my Java skill limits quickly.

 
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 06:51:13 AM
Progress (http://www.scriptbasic.org/forum/index.php/topic,283.0.html)
Title: Re: JAPI 2.0
Post by: Cybermonkey on May 27, 2013, 08:05:18 AM
Ok, now what's the secret?
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 08:16:01 AM
It seems the default Windows LaF (Look and Feel) works with JAPI without causing errors or missing intended functionality. The button issue with the LaF is not unique to JAPI but the default for the theme. I created a swing.properties file with the following and placed it in the jre->lib directory.

Code: [Select]
swing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel

The buttons look great but we lose setting background colors (same on Linux) using the Metal theme. There are other issues as well. I think if we fix the deprecated code and bring it current, the issues will go away on all platforms. IMHO

Title: Re: JAPI 2.0
Post by: Cybermonkey on May 27, 2013, 08:44:00 AM
Ok, good to know. Hey, Marcus, we need a Java Guru ...  ::)
BTW, what I think is, if this kind of library is possible with SWING/AWT, this could work with others, too. For example could it be possible (for Marcus ;) ) to make a game development library out of his Java code for other compilers/interpreters? A kind of naalaa.dll/.so. Or might we even use the jMonkey engine with ScriptBasic??
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 08:49:25 AM
(http://files.allbasic.info/JAPI/gridlayout.png)

If you use the following swing.properties file setting the Window XP theming on buttons works. (but has the same issues as Metal)

swing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel

Quote
Version Note: As of release 1.4.2, WindowsLookAndFeel has been updated to mimic the Windows XP look and feel when running on the Windows XP platform.

Title: Re: JAPI 2.0
Post by: Mopz on May 27, 2013, 03:59:48 PM
Sorry, had a rough week and weekend.

And I'm also sorry for having to disappoint you: I'm terrible at Java  :(  As I wrote, I used Java many years ago, but it was no deep work. Today I do use Java every now and then, but that's just for creating android extensions for the lovely Marmalade framework.

In order to figure out what's going on here I better do some reading on the scriptbasic forum, and I'll do that as soon as I get hold of some time :) I wish you could buy that rare substance in a bottle or box somewhere
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 04:16:59 PM
Here is the deprecated hit list for the swing directory version of JAPI.

Code: [Select]
javac -Xlint:deprecation -O JAPI.java && jar cf JAPI.jar *.class
./JAPI_Alert.java:159: warning: [deprecation] reshape(int,int,int,int) in java.awt.Window has been deprecated
this.reshape(xpos,ypos,this.getSize().width,this.getSize().height);
    ^
./JAPI_Alert.java:160: warning: [deprecation] show() in java.awt.Dialog has been deprecated
this.show();
    ^
./JAPI_Thread.java:94: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
clienthost = in.readLine();
               ^
./JAPI_Thread.java:534: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                  String s = in.readLine();
                               ^
./JAPI_Thread.java:632: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      String title  = in.readLine();
                                        ^
./JAPI_Thread.java:1102: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
              String file = in.readLine();
                              ^
./JAPI_Thread.java:1115: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
              String file = in.readLine();
                              ^
./JAPI_Thread.java:1252: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                  String title = in.readLine();
                                   ^
./JAPI_Thread.java:1313: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
              String item = in.readLine();
                              ^
./JAPI_Thread.java:1317: warning: [deprecation] addItem(java.lang.String,int) in java.awt.List has been deprecated
((List)o[obj]).addItem(item,pos);
              ^
./JAPI_Thread.java:1343: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
            String item   = in.readLine();
                              ^
./JAPI_Thread.java:1421: warning: [deprecation] disable() in java.awt.Component has been deprecated
                ((Component)o[obj]).disable();
                                   ^
./JAPI_Thread.java:1423: warning: [deprecation] disable() in java.awt.MenuItem has been deprecated
                ((JAPI_Menu)o[obj]).disable();
                                   ^
./JAPI_Thread.java:1425: warning: [deprecation] disable() in java.awt.MenuItem has been deprecated
                ((MenuItem)o[obj]).disable();
                                  ^
./JAPI_Thread.java:1427: warning: [deprecation] disable() in java.awt.MenuItem has been deprecated
              ((CheckboxMenuItem)o[obj]).disable();
                                        ^
./JAPI_Thread.java:1439: warning: [deprecation] enable() in java.awt.Component has been deprecated
                ((Component)o[obj]).enable();
                                   ^
./JAPI_Thread.java:1441: warning: [deprecation] enable() in java.awt.MenuItem has been deprecated
                ((JAPI_Menu)o[obj]).enable();
                                   ^
./JAPI_Thread.java:1443: warning: [deprecation] enable() in java.awt.MenuItem has been deprecated
                ((MenuItem)o[obj]).enable();
                                  ^
./JAPI_Thread.java:1445: warning: [deprecation] enable() in java.awt.MenuItem has been deprecated
              ((CheckboxMenuItem)o[obj]).enable();
                                        ^
./JAPI_Thread.java:1997: warning: [deprecation] replaceText(java.lang.String,int,int) in java.awt.TextArea has been deprecated
((TextArea)o[obj]).replaceText("",start,end);
                  ^
./JAPI_Thread.java:2181: warning: [deprecation] isSelected(int) in java.awt.List has been deprecated
              out.sendInt(((JAPI_List)o[obj]).isSelected(index)?JAPI_Const.J_TRUE:JAPI_Const.J_FALSE);
                                             ^
./JAPI_Thread.java:2659: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                String str = in.readLine();
                               ^
./JAPI_Thread.java:2937: warning: [deprecation] hide() in java.awt.Component has been deprecated
  ((Component)o[i]).hide();
                   ^
./JAPI_Thread.java:3087: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
               title = in.readLine();
                         ^
./JAPI_Thread.java:3121: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3264: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3285: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    String icon = in.readLine();
                                    ^
./JAPI_Thread.java:3307: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3330: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    String icon = in.readLine();
                                    ^
./JAPI_Thread.java:3351: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3394: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3524: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3551: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3572: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3592: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3614: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3650: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                       String Appath = in.readLine();
                                         ^
./JAPI_Thread.java:3651: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3652: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    String dir = in.readLine();
                                   ^
./JAPI_Thread.java:3671: warning: [deprecation] show() in java.awt.Dialog has been deprecated
                          f.show();
                           ^
./JAPI_Thread.java:3715: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3743: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3744: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3769: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3770: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3771: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but2 = in.readLine();
                                     ^
./JAPI_Thread.java:3796: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3797: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3798: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but2 = in.readLine();
                                     ^
./JAPI_Thread.java:3799: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                     String but3 = in.readLine();
                                     ^
./JAPI_Thread.java:3920: warning: [deprecation] readLine() in java.io.DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Debugwindow.java:26: warning: [deprecation] show() in java.awt.Window has been deprecated
this.show();
    ^
./JAPI_Debugwindow.java:28: warning: [deprecation] hide() in java.awt.Window has been deprecated
this.hide();
    ^
./JAPI_Debugwindow.java:34: warning: [deprecation] appendText(java.lang.String) in java.awt.TextArea has been deprecated
text.appendText(zeilen+": "+s+"\n");
    ^
./JAPI_MultiLineLabel.java:107: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
    public Dimension preferredSize() {
                     ^
./JAPI_MultiLineLabel.java:114: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
    public Dimension minimumSize() {
                     ^
./JAPI_MultiLineLabel.java:124: warning: [deprecation] size() in java.awt.Component has been deprecated
        Dimension d = this.size();
                          ^
./JAPI_VFlowlayout.java:103: warning: [deprecation] countComponents() in java.awt.Container has been deprecated
int nmembers = target.countComponents();
                     ^
./JAPI_VFlowlayout.java:110: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension d = m.preferredSize();
               ^
./JAPI_VFlowlayout.java:126: warning: [deprecation] countComponents() in java.awt.Container has been deprecated
int nmembers = target.countComponents();
                     ^
./JAPI_VFlowlayout.java:133: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
Dimension d = m.minimumSize();
               ^
./JAPI_VFlowlayout.java:150: warning: [deprecation] size() in java.awt.Component has been deprecated
int maxheight = target.size().height - (insets.top  + insets.bottom);
                      ^
./JAPI_VFlowlayout.java:151: warning: [deprecation] size() in java.awt.Component has been deprecated
int maxwidth  = target.size().width  - (insets.left + insets.right);
                      ^
./JAPI_VFlowlayout.java:152: warning: [deprecation] countComponents() in java.awt.Container has been deprecated
int nmembers  = target.countComponents();
                      ^
./JAPI_VFlowlayout.java:166: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension d = m.preferredSize();
               ^
./JAPI_VFlowlayout.java:185: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension d = m.preferredSize();
               ^
./JAPI_VFlowlayout.java:210: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension d = m.preferredSize();
               ^
./JAPI_VFlowlayout.java:249: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension d = m.preferredSize();
               ^
./JAPI_Ruler.java:33: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
public Dimension preferredSize()
                 ^
./JAPI_Ruler.java:35: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension dim = super.preferredSize();
                     ^
./JAPI_Ruler.java:41: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
public Dimension minimumSize()
                 ^
./JAPI_Ruler.java:43: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
Dimension dim = super.minimumSize();
                     ^
./JAPI_Canvas.java:58: warning: [deprecation] size() in java.awt.Component has been deprecated
Dimension d = super.size();
                   ^
./JAPI_Canvas.java:125: warning: [deprecation] size() in java.awt.Component has been deprecated
Dimension d = super.size();
                   ^
./JAPI_Canvas.java:210: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
public Dimension preferredSize()
                 ^
./JAPI_Canvas.java:212: warning: [deprecation] preferredSize() in java.awt.Component has been deprecated
Dimension dim = super.preferredSize();
                     ^
./JAPI_Canvas.java:218: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
public Dimension minimumSize()
                 ^
./JAPI_Canvas.java:220: warning: [deprecation] minimumSize() in java.awt.Component has been deprecated
Dimension dim = super.minimumSize();
                     ^
./JAPI_Frame.java:29: warning: [deprecation] disable() in java.awt.Component has been deprecated
public void disable()
            ^
./JAPI_Frame.java:33: warning: [deprecation] disable() in java.awt.Component has been deprecated
getComponent(i).disable();
               ^
./JAPI_Frame.java:38: warning: [deprecation] enable() in java.awt.Component has been deprecated
public void enable()
            ^
./JAPI_Frame.java:42: warning: [deprecation] enable() in java.awt.Component has been deprecated
getComponent(i).enable();
               ^
./JAPI_Frame.java:74: warning: [deprecation] getPeer() in java.awt.Component has been deprecated
if(getComponent(i).getPeer() != null)
                  ^
./JAPI_Dialog.java:27: warning: [deprecation] disable() in java.awt.Component has been deprecated
public void disable()
            ^
./JAPI_Dialog.java:30: warning: [deprecation] disable() in java.awt.Component has been deprecated
getComponent(i).disable();
               ^
./JAPI_Dialog.java:33: warning: [deprecation] enable() in java.awt.Component has been deprecated
public void enable()
            ^
./JAPI_Dialog.java:36: warning: [deprecation] enable() in java.awt.Component has been deprecated
getComponent(i).enable();
               ^
./JAPI_Dialog.java:56: warning: [deprecation] getPeer() in java.awt.Component has been deprecated
if(getComponent(i).getPeer() != null)
                  ^
./JAPI_Window.java:14: warning: [deprecation] disable() in java.awt.Component has been deprecated
public void disable()
            ^
./JAPI_Window.java:18: warning: [deprecation] disable() in java.awt.Component has been deprecated
getComponent(i).disable();
               ^
./JAPI_Window.java:21: warning: [deprecation] enable() in java.awt.Component has been deprecated
public void enable()
            ^
./JAPI_Window.java:25: warning: [deprecation] enable() in java.awt.Component has been deprecated
getComponent(i).enable();
               ^
./JAPI_Window.java:46: warning: [deprecation] getPeer() in java.awt.Component has been deprecated
if(getComponent(i).getPeer() != null)
                  ^
./JAPI_Panel.java:17: warning: [deprecation] disable() in java.awt.Component has been deprecated
public void disable()
            ^
./JAPI_Panel.java:21: warning: [deprecation] disable() in java.awt.Component has been deprecated
getComponent(i).disable();
               ^
./JAPI_Panel.java:24: warning: [deprecation] enable() in java.awt.Component has been deprecated
public void enable()
            ^
./JAPI_Panel.java:28: warning: [deprecation] enable() in java.awt.Component has been deprecated
getComponent(i).enable();
               ^
./JAPI_Panel.java:49: warning: [deprecation] getPeer() in java.awt.Component has been deprecated
if(getComponent(i).getPeer() != null)
                  ^
./JAPI_Panel.java:55: warning: [deprecation] size() in java.awt.Component has been deprecated
        Dimension d = size();
                      ^
./JAPI_List.java:38: warning: [deprecation] preferredSize() in java.awt.List has been deprecated
public Dimension preferredSize()
                 ^
Note: Some input files additionally use or override a deprecated API.
100 warnings

Before doing anything, we need to clean up this list. IMHO

Title: Re: JAPI 2.0
Post by: Mopz on May 27, 2013, 04:50:08 PM
Yep. In most cases it should be straight forward. For example, The reshape method has been replaced with setBounds, show has been replaced with setVisible, a bufferedreader should be used instead of a datainputstream for reading lines, etc.  All can be found in the docs at oracle. I've looked at the japi webpage, and it's hard to understand why such a nice project was abandoned  :(  I'll see what I can do to help, but, as I said I'm quite busy  :)
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 04:53:13 PM
I love it when you talk Java.  ;D

It seems to be a lot of the same issues so if you can create a list of what needs to be changed, I take a shot at implementing it.

Title: Re: JAPI 2.0
Post by: Mopz on May 27, 2013, 05:01:16 PM
Ok, added another example in my previous post.

Dialog.show() / hide() - use setVisible(true/false), same for Window I think

List.addItem(...) - use add(...)

Component.enable() / disable() - use setEnabled(true/false), same for MenuItem

TextArea.replaceText(...) - use replaceRange(...)

List.isSelected(...) - use isIndexSelected(...)

TextArea.appendText(...) - use append(...)

Component.preferredSize() - use getPreferredSize()

Component ... for everything with ...size(), just add "get" to the beginning of the method name :)

Container.countComponents() - use getComponentCount()

"         if(getComponent(i).getPeer() != null)"  use " if (getComponent(i).isDisplayable())"


That ought to be it. A DataInputStream can be boxed into a BufferedReader with:


Code: [Select]
BufferedReader br = new BufferedReader(new InputStreamReader(in));
Then you can use br.readLine() instead of in.readLine().
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 27, 2013, 05:38:31 PM
I think we should reinstate Marcus as the Programmer of the Year again on the Basic Programming forum.  8)

Your the man! I'll take a shot at cleaning this up and get back to you guys.

Title: Re: JAPI 2.0
Post by: Mopz on May 27, 2013, 06:00:09 PM
Thanks, but it was just about looking in the javadocs. And obviously 98% of the deprecations were method name changes. But I'm in on this, for naalaa, so I hope you can supply a new lib when it works :)
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 12:17:00 AM
Quote
a bufferedreader should be used instead of a datainputstream for reading lines, etc.

JAPI_Thread.java (starting at line 73)
Code: [Select]
            in = new JAPI_SocketInputStream(commandsock.getInputStream());
            out = new JAPI_SocketOutputStream(commandsock.getOutputStream());
            action = new JAPI_SocketOutputStream(actionsock.getOutputStream());

  /* magic number for swap test */
out.sendInt(1234);

/* Debuglevel und window */
o[0]=null;
debug=in.recvInt();
            o[1] = new JAPI_Debugwindow(debug);
            debugwindow = (JAPI_Debugwindow)o[1];
            o[2] = new JAPI_Errordialog(debugwindow);
            errordialog = (JAPI_Errordialog)o[2];
            objectcounter=3;
            if(debug>0) debugwindow.println("Debug Level : "+debug);
            if(debug>0) debugwindow.println("Commandstream connected");
            if(debug>0) debugwindow.println("Actionstream  connected");


/* Clienthost and HTTP Port */
clienthost = in.readLine();
httpport   = in.recvInt();
  if(debug>0) debugwindow.println("Display   : "+clienthost);
if(debug>0) debugwindow.println("HTTP Port : "+httpport);

Marcus,

The readLine() deprecated method is everywhere and I want to make sure I understand what I need to change so I don't waste a bunch of time having to redo it. Is the deprecated method only a read issue and the old way of writing to the output device is fine?

John
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 07:04:07 AM
Marcus,

I notice this reference to show that didn't appear in the deprecation list. Is this a different type of method?

Code: [Select]
/* Show Popuop */
                if (command == JAPI_Calls.JAPI_SHOWPOPUP)
              {
              int x     = in.recvInt();
              int y     = in.recvInt();

if(debug>2) debugwindow.println("Show Popup "+o[obj].toString()+" at "+x+":"+y);
if(o[obj] instanceof PopupMenu)
((PopupMenu)o[obj]).show((Component)(((Menu)o[obj]).getParent()),x,y);
            else
            nextaction=errordialog.getResult("No Popup ID in j_showpopup( ID , ... )\nID = "+o[obj].toString());
                    continue;
}
Title: Re: JAPI 2.0
Post by: Mopz on May 28, 2013, 07:20:42 AM
Quote
a bufferedreader should be used instead of a datainputstream for reading lines, etc.

JAPI_Thread.java (starting at line 73)
Code: [Select]
            in = new JAPI_SocketInputStream(commandsock.getInputStream());
            out = new JAPI_SocketOutputStream(commandsock.getOutputStream());
            action = new JAPI_SocketOutputStream(actionsock.getOutputStream());

  /* magic number for swap test */
out.sendInt(1234);

/* Debuglevel und window */
o[0]=null;
debug=in.recvInt();
            o[1] = new JAPI_Debugwindow(debug);
            debugwindow = (JAPI_Debugwindow)o[1];
            o[2] = new JAPI_Errordialog(debugwindow);
            errordialog = (JAPI_Errordialog)o[2];
            objectcounter=3;
            if(debug>0) debugwindow.println("Debug Level : "+debug);
            if(debug>0) debugwindow.println("Commandstream connected");
            if(debug>0) debugwindow.println("Actionstream  connected");


/* Clienthost and HTTP Port */
clienthost = in.readLine();
httpport   = in.recvInt();
  if(debug>0) debugwindow.println("Display   : "+clienthost);
if(debug>0) debugwindow.println("HTTP Port : "+httpport);

Marcus,

The readLine() deprecated method is everywhere and I want to make sure I understand what I need to change so I don't waste a bunch of time having to redo it. Is the deprecated method only a read issue and the old way of writing to the output device is fine?

John

I think the output streams are safe. There was a bug in readLine for the DataInputStream, and that's why it was deprecated. I guess old programs took the bug into account, and therefor they deprecated the function rather than fixing it.
Title: Re: JAPI 2.0
Post by: Mopz on May 28, 2013, 07:22:35 AM
Marcus,

I notice this reference to show that didn't appear in the deprecation list. Is this a different type of method?

Code: [Select]
/* Show Popuop */
                if (command == JAPI_Calls.JAPI_SHOWPOPUP)
              {
              int x     = in.recvInt();
              int y     = in.recvInt();

if(debug>2) debugwindow.println("Show Popup "+o[obj].toString()+" at "+x+":"+y);
if(o[obj] instanceof PopupMenu)
((PopupMenu)o[obj]).show((Component)(((Menu)o[obj]).getParent()),x,y);
            else
            nextaction=errordialog.getResult("No Popup ID in j_showpopup( ID , ... )\nID = "+o[obj].toString());
                    continue;
}

Yep, the show method for PopupMenu is not  deprecated.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 07:27:07 AM
Quote
I think the output streams are safe. There was a bug in readLine for the DataInputStream, and that's why it was deprecated. I guess old programs took the bug into account, and therefor they deprecated the function rather than fixing it.

Can you post the fix for this? The socket thing is confusing me when trying to search for help with Google. I'm thinking nothing needs to be done for the readLine() methods and only the DataInputStream syntax needs fixing.

Title: Re: JAPI 2.0
Post by: Mopz on May 28, 2013, 08:12:45 AM
I can't do much right now (I'm at work). But what confuses me is the recvInt method. I've checked the javadocs and DataInputStream does not have such a method, nor does BufferedReader. What type of object are we dealing with?

Code: [Select]
in = new JAPI_SocketInputStream(commandsock.getInputStream());
This suggests it's a SocketInputStream. But I can't find anything about that class on oracle. On other places I've found the class but no information about the recvInt method. Perhaps the class is the JAPI authors own construct? Is there a SocketInputStream.java file that I can look at?
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 08:47:05 AM
Quote
This suggests it's a SocketInputStream. But I can't find anything about that class on oracle. On other places I've found the class but no information about the recvInt method. Perhaps the class is the JAPI authors own construct? Is there a SocketInputStream.java file that I can look at?

Not that I could find. Attached is my current state of the JAPI 2.0 swing source. JAPI_Thread.java only needs the SocketInputStream issue addressed.

Note: I'm working under Linux so the source files are not in DOS format.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 09:45:38 AM
Code: [Select]
public Dimension getpreferredSize() // JAPI2
{
Dimension dim = super.getpreferredSize(); // JAPI2
dim.width  = w>0 ? w : dim.width;
dim.height = h>0 ? h : dim.height;
return(dim);
}

public Dimension getminimumSize() // JAPI2
{
Dimension dim = super.getminimumSize(); // JAPI2
dim.width  = w>0 ? w : dim.width;
dim.height = h>0 ? h : dim.height;
return(dim);
}

Marcus,

The dep list only indicates that the public Dimension preferredSize() needs to be changes but I think the Dimension dim = super.preferredSize(); needs to be changed as well. Your thoughts ...
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 10:02:38 AM
I'm thinking that this deprecation detector is flawed.

Here is what it says are the problems.

Code: [Select]
./JAPI_Frame.java:29: warning: [deprecation] disable() in java.awt.Component has been deprecated
public void disable()
            ^
./JAPI_Frame.java:33: warning: [deprecation] disable() in java.awt.Component has been deprecated
getComponent(i).disable();
               ^
./JAPI_Frame.java:38: warning: [deprecation] enable() in java.awt.Component has been deprecated
public void enable()
            ^
./JAPI_Frame.java:42: warning: [deprecation] enable() in java.awt.Component has been deprecated
getComponent(i).enable();
               ^

Here are the changes I made. (code starts at line 29)

Code: [Select]

// public void paint(Graphics g)
// {
//     if(isResizable()!=resizable)
//     super.setResizable(resizable);
// }

public void disable()
{
int i;
for(i=0;i<getComponentCount();i++)
getComponent(i).setEnabled(false); // JAPI2
if(getJMenuBar() != null)
((JAPI_Menubar)getJMenuBar()).setEnabled(false); // JAPI2
}

public void enable()
{
int i;
  for(i=0;i<getComponentCount();i++)
getComponent(i).setEnabled(true); // JAPI2
if(getJMenuBar() != null)
((JAPI_Menubar)getJMenuBar()).setEnabled(true); // JAPI2
}

I'm wondering if the enable() / disable() user functions are overloading the Java defaults. If so, we are using a single function now and have two routines. I'm wondering if the enable() / disable() are high level methods that controls/users access and not the Java standard methods directly. Sorry for being such a dumb ass about Java.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 06:15:41 PM
I have finished with the JAPI 2.0 deprecation updates based on fix list. I still need to address the above issues when you have time.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 07:42:58 PM
I thought I would give what I have done so far a test compile and see what warnings/errors would still be present. I think we may have missed the boat on a few of the translations. I'm still new at Java to make any guesses or determinations at this point.

I attached the compete error/warning output as it exceeded the max post size.

I have noticed new deprecation errors that didn't show up in the last list. I'm getting the sickening feeling that the -Xlint:deprecation only spits out 100 at a time.  :-[

Code: [Select]
javac -Xlint:deprecation -O JAPI.java && jar cf JAPI.jar *.class *.gif
./JAPI_Alert.java:160: error: no suitable method found for setVisible()
this.setVisible(); // JAPI2
    ^
    method Dialog.setVisible(boolean) is not applicable
      (actual and formal argument lists differ in length)
./JAPI_MultiLineLabel.java:124: error: cannot find symbol
        Dimension d = this.getsize(); // JAPI2
                          ^
  symbol: method getsize()
./JAPI_VFlowlayout.java:110: error: cannot find symbol
Dimension d = m.getpreferredSize(); // JAPI2
               ^
  symbol:   method getpreferredSize()
  location: variable m of type Component
./JAPI_VFlowlayout.java:133: error: cannot find symbol
Dimension d = m.getminimumSize(); // JAPI2
               ^
  symbol:   method getminimumSize()
  location: variable m of type Component
./JAPI_VFlowlayout.java:150: error: cannot find symbol
int maxheight = target.getsize().height - (insets.top  + insets.bottom); // JAPI2
                      ^
  symbol:   method getsize()
  location: variable target of type Container
./JAPI_VFlowlayout.java:151: error: cannot find symbol
int maxwidth  = target.getsize().width  - (insets.left + insets.right); // JAPI2
                      ^
  symbol:   method getsize()
  location: variable target of type Container
./JAPI_VFlowlayout.java:166: error: cannot find symbol
Dimension d = m.getpreferredSize(); // JAPI2
               ^
  symbol:   method getpreferredSize()
  location: variable m of type Component
./JAPI_VFlowlayout.java:185: error: cannot find symbol
Dimension d = m.getpreferredSize(); // JAPI2
               ^
  symbol:   method getpreferredSize()
  location: variable m of type Component
./JAPI_VFlowlayout.java:210: error: cannot find symbol
Dimension d = m.getpreferredSize(); // JAPI2
               ^
  symbol:   method getpreferredSize()
  location: variable m of type Component
./JAPI_VFlowlayout.java:249: error: cannot find symbol
Dimension d = m.getpreferredSize(); // JAPI2
               ^
  symbol:   method getpreferredSize()
  location: variable m of type Component
./JAPI_Ruler.java:43: error: cannot find symbol
Dimension dim = super.getminimumSize(); // JAPI2
                     ^
  symbol: method getminimumSize()
./JAPI_Canvas.java:59: error: cannot find symbol
Dimension d = super.getsize(); // JAPI2
                   ^
  symbol: method getsize()
./JAPI_Canvas.java:126: error: cannot find symbol
Dimension d = super.getsize(); // JAPI2
                   ^
  symbol: method getsize()
./JAPI_Canvas.java:213: error: cannot find symbol
Dimension dim = super.getpreferredSize(); // JAPI2
                     ^
  symbol: method getpreferredSize()
./JAPI_Canvas.java:221: error: cannot find symbol
Dimension dim = super.getminimumSize(); // JAPI2
                     ^
  symbol: method getminimumSize()
./JAPI_Panel.java:55: error: cannot find symbol
        Dimension d = getsize(); // JAPI2
                      ^
  symbol:   method getsize()
  location: class JAPI_Panel
./JAPI_List.java:40: error: cannot find symbol
Dimension dim = super.getpreferredSize(); // JAPI2
                     ^
  symbol: method getpreferredSize()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
17 errors
make: *** [JAPI.jar] Error 1
jrs@laptop:~/japi/japilib/swing$
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 28, 2013, 08:31:51 PM
I found what looks like a usable deprecated method conversion list (http://docs.oracle.com/javase/7/docs/api/deprecated-list.html#method).

I have also noticed that Java is CaSe sensitive and the reason my change from size() to getsize() should have been getSize().

Back to the list and hope I have better luck this time.

@Marcus - If you can figure out the readline() issue, that would be really helpful.



Title: Re: JAPI 2.0
Post by: ScriptBasic on May 29, 2013, 03:01:22 AM
I have upgraded the Java code to fix most of the deprecated methods. I still have the same component issues using a theme as I did before the upgrade. The following warnings are beyond my skills to fix. I have attached the JAPI2 Java source if someone wishes to try and take this to the next step.

Code: [Select]
javac -Xlint:deprecation -O JAPI.java && jar cf JAPI.jar *.class *.gif
./JAPI_Thread.java:94: warning: [deprecation] readLine() in DataInputStream has been deprecated
clienthost = in.readLine();
               ^
./JAPI_Thread.java:534: warning: [deprecation] readLine() in DataInputStream has been deprecated
                  String s = in.readLine();
                               ^
./JAPI_Thread.java:632: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      String title  = in.readLine();
                                        ^
./JAPI_Thread.java:1097: warning: [deprecation] readLine() in DataInputStream has been deprecated
              String file = in.readLine();
                              ^
./JAPI_Thread.java:1110: warning: [deprecation] readLine() in DataInputStream has been deprecated
              String file = in.readLine();
                              ^
./JAPI_Thread.java:1247: warning: [deprecation] readLine() in DataInputStream has been deprecated
                  String title = in.readLine();
                                   ^
./JAPI_Thread.java:1308: warning: [deprecation] readLine() in DataInputStream has been deprecated
              String item = in.readLine();
                              ^
./JAPI_Thread.java:1338: warning: [deprecation] readLine() in DataInputStream has been deprecated
            String item   = in.readLine();
                              ^
./JAPI_Thread.java:1620: warning: [deprecation] setLabel(String) in AbstractButton has been deprecated
                ((JAPI_Button)o[obj]).setLabel(newtext);
                                     ^
./JAPI_Thread.java:1624: warning: [deprecation] setLabel(String) in AbstractButton has been deprecated
                ((JAPI_Menu)o[obj]).setLabel(newtext);
                                   ^
./JAPI_Thread.java:2254: warning: [deprecation] getLabel() in AbstractButton has been deprecated
  inhalt=((JAPI_Button)o[obj]).getLabel();
                              ^
./JAPI_Thread.java:2256: warning: [deprecation] getLabel() in AbstractButton has been deprecated
                inhalt=((JAPI_Menu)o[obj]).getLabel();
                                          ^
./JAPI_Thread.java:2360: warning: [deprecation] getLabel() in AbstractButton has been deprecated
  out.sendInt(((JAPI_Button)o[obj]).getLabel().length());
                                   ^
./JAPI_Thread.java:2362: warning: [deprecation] getLabel() in AbstractButton has been deprecated
                out.sendInt(((JAPI_Menu)o[obj]).getLabel().length());
                                               ^
./JAPI_Thread.java:2603: warning: [deprecation] readLine() in DataInputStream has been deprecated
                String str = in.readLine();
                               ^
./JAPI_Thread.java:3031: warning: [deprecation] readLine() in DataInputStream has been deprecated
               title = in.readLine();
                         ^
./JAPI_Thread.java:3065: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3208: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3229: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    String icon = in.readLine();
                                    ^
./JAPI_Thread.java:3251: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3274: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    String icon = in.readLine();
                                    ^
./JAPI_Thread.java:3295: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3338: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Thread.java:3468: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3495: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3516: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3536: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3558: warning: [deprecation] readLine() in DataInputStream has been deprecated
                      title = in.readLine();
                                ^
./JAPI_Thread.java:3594: warning: [deprecation] readLine() in DataInputStream has been deprecated
                       String Appath = in.readLine();
                                         ^
./JAPI_Thread.java:3595: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3596: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    String dir = in.readLine();
                                   ^
./JAPI_Thread.java:3651: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3679: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3680: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3705: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3706: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3707: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but2 = in.readLine();
                                     ^
./JAPI_Thread.java:3732: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     title = in.readLine();
                               ^
./JAPI_Thread.java:3733: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but1 = in.readLine();
                                     ^
./JAPI_Thread.java:3734: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but2 = in.readLine();
                                     ^
./JAPI_Thread.java:3735: warning: [deprecation] readLine() in DataInputStream has been deprecated
                     String but3 = in.readLine();
                                     ^
./JAPI_Thread.java:3864: warning: [deprecation] readLine() in DataInputStream has been deprecated
                    title = in.readLine();
                              ^
./JAPI_Frame.java:34: warning: [deprecation] disable() in Component has been deprecated
public void disable()
            ^
./JAPI_Frame.java:43: warning: [deprecation] enable() in Component has been deprecated
public void enable()
            ^
./JAPI_Dialog.java:27: warning: [deprecation] disable() in Component has been deprecated
public void disable()
            ^
./JAPI_Dialog.java:33: warning: [deprecation] enable() in Component has been deprecated
public void enable()
            ^
./JAPI_Window.java:14: warning: [deprecation] disable() in Component has been deprecated
public void disable()
            ^
./JAPI_Window.java:21: warning: [deprecation] enable() in Component has been deprecated
public void enable()
            ^
./JAPI_Panel.java:17: warning: [deprecation] disable() in Component has been deprecated
public void disable()
            ^
./JAPI_Panel.java:24: warning: [deprecation] enable() in Component has been deprecated
public void enable()
            ^
./JAPI_Graphicbutton.java:64: warning: [deprecation] disable() in Component has been deprecated
public void disable()
            ^
./JAPI_Graphicbutton.java:71: warning: [deprecation] enable() in Component has been deprecated
public void enable()
            ^
./JAPI_Graphicbutton.java:97: warning: [deprecation] mouseUp(Event,int,int) in Component has been deprecated
  public boolean mouseUp(Event evt, int x, int y)
                 ^
./JAPI_Graphicbutton.java:112: warning: [deprecation] mouseDown(Event,int,int) in Component has been deprecated
  public boolean mouseDown(Event evt, int x, int y)
                 ^
./JAPI_Graphicbutton.java:119: warning: [deprecation] mouseExit(Event,int,int) in Component has been deprecated
  public boolean mouseExit(Event evt, int x, int y)
                 ^
./JAPI_Graphicbutton.java:127: warning: [deprecation] mouseEnter(Event,int,int) in Component has been deprecated
  public boolean mouseEnter(Event evt, int x, int y)
                 ^
./JAPI_Menubar.java:11: warning: [deprecation] disable() in JComponent has been deprecated
    public void disable()
                ^
./JAPI_Menubar.java:18: warning: [deprecation] enable() in JComponent has been deprecated
    public void enable()
                ^
58 warnings
jrs@laptop:~/japi/japilib/swing$
Title: Re: JAPI 2.0
Post by: DJLinux on May 29, 2013, 03:28:30 AM
In the case you use class DataInputStream you have to change to the BufferedReader class ?

DJ
Quote from: JAVA Deprecated API
java.io.DataInputStream.readLine()
This method does not properly convert bytes to characters.
As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method.
Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:

         DataInputStream d = new DataInputStream(in);
with:
         BufferedReader d = new BufferedReader(new InputStreamReader(in));
     
Title: Re: JAPI 2.0
Post by: Mopz on May 29, 2013, 05:13:12 PM
I'm sorry, I think I need to spend some time on understanding how JAPI works before I try to answer any questions. So far, I've just had a first VERY short glance at JAPI.

JAPI uses AWT and SWING. And we're using the latest version of these api:s, right? Unless JAPI uses a big set of new classes and inheritence, there should only be "one level of deprecation" to deal with. That is, we should only need to replace deprecated function calls at one level, not through a "whole family tree" of inheritance. 

I think I need to make my woman pregnant again so that I'll can be parental for six months or so (love the Swedish system) and have serious time for personal programming :) Right now I deal with naalaa and forum activity between work, cooking and diaper changes.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 29, 2013, 05:27:17 PM
I updated most of the common sense based deprecated methods to bring it to where it is now. This is what I'm in the dark about.

What does LaF do to JAPI that breaks the code and works if no LaF is defined? The button.bas works perfect with themes. The LED and Meter examples just hang. The gridlayout stops working thinking it's parent is lying.

Is there a special include that is needed at the top of the .java programs that brings the theme functionality into play?

I seem to be screwed at the moment. Ever since I added the swing.properties file to enable theming, I can't return back to no LaF support. :(


Title: Re: JAPI 2.0
Post by: Mopz on May 29, 2013, 06:21:33 PM
Sorry John, I've got to spend some real time on this project before I can be of assistance. Hopefully I'll have the time this weekend.
Title: Re: JAPI 2.0
Post by: ScriptBasic on May 29, 2013, 07:51:35 PM
No problem. I'm preoccupied with the new JIT compiling feature Charles added to DLLC at the moment. I'll be happy to jump back on board once the Java (JAPI.jar) is sound. I see adding the TAB/Notebook control as a must have to make this really useful as a GUI alternative.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 30, 2013, 08:13:49 AM
Update

My non-LaF setting returned to normal and I was able to test the upgraded DLL. Everything seems to work fine. Getting theme support to work has to be the next thing we need to get going. IMHO

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 31, 2013, 03:01:59 AM
I made 272 deprecation upgrades to the original JAPI 1.06 code. There is still 58 warnings remaining. The library only partially works if theming (LaF) is enabled. My brief testing of the upgraded JAPI 2.0 DLL seemed to work and not introducing any additional problems.

That's where things are and handing the wheel over to Marcus.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 04, 2013, 05:58:40 PM
Just sitting here in the back of the bus and the scenery doesn't seem to be changing. Are we broke down? Is there anyone else beside overwhelmed Marcus out there with a Java background that can help move this along?

Title: Re: JAPI 2.0
Post by: Mopz on June 05, 2013, 07:28:57 PM
Just sitting here in the back of the bus and the scenery doesn't seem to be changing. Are we broke down? Is there anyone else beside overwhelmed Marcus out there with a Java background that can help move this along?

Just sitting here in the sofa, after a day of writing marmalade extensions for Samsung's Plasma and Adhub android SDK:s. The point being, that I've got a fulltime job as lead programmer at a game company, three kids, a fiancee with a great career ... I have less than little sparetime  :) Most evenings I give into beer rather than programming. I'm sure I could solve these issues in half an hour, but half hours are so rare ...

Edit: And the other night I was watching Eyes Wide Shut and thought: "Hm ... that'd be nice ..." Yes, I'm drunk and feeling sorry for myself.
Title: Re: JAPI 2.0
Post by: Mopz on June 05, 2013, 07:39:48 PM
But my Java background IS weak. I know the language and could solve the issues by using the docs from Oracle and anything found on the internet. But if someone here's got some REAL java knowledge, please give this a shot :)
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 05, 2013, 09:51:34 PM
JAPI isn't my main focus either. I like the library and have this gut feeling it would only take you an hour or less to solve the few issues that persist.

Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 04:10:43 AM
I thought I would mention that if I use the following LaF (lookAndFeel) setting for Windows, all the test programs work. Any other LaF setting breaks things. With that tidbit, what do you think is causing the breakdown with more enhanced themes? (using latest deprecation updated DLL)

swing.properties
Code: [Select]
swing.defaultlaf=com.sun.java.swing.plaf.basic
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 05:46:58 AM
As incentive, here is a ScriptBasic/JAPI example of the Chaos Theory (http://en.wikipedia.org/wiki/Chaos_theory). (butterfly effect)

(http://files.allbasic.info/ScriptBasic/butterfly.png)

Code: [Select]
import japi.bas

j_start
win = j_frame("Peter's Butterfly")
can = j_canvas(win, 640, 480)
j_pack(win)
j_show(win)

x =  0.0
y = 20.0
z = 20.0

j_setnamedcolorbg(can, J_BLACK)

while obj <> win
  xx = x + 0.01 * ( -10.0 * x + 10.0 * y)
  yy = y + 0.01 * (  28.0 * x - y - x * z )
  zz = z + 0.01 * ( -8.0  * z / 3.0  + x * y )
  j_setcolor(can, Rnd(), Rnd(), Rnd())
  j_drawline(can, x*10+320, -z*10+500, xx*10+320, -zz*10+500)
  x = xX
  y = yY
  z = zZ
  obj = j_getaction()
wend                         
j_quit
Title: Re: JAPI 2.0
Post by: Mopz on June 06, 2013, 07:52:03 AM
Can you zip and post (or e-mail to marcus@naalaa.com) everything you've got (including the script basic examples)? It's also possible to change the L&F programmatically, but unless that is actually done somewhere in the swing version of JAPI (which could cause errors and conflicts) I have no idea why changing the props file shouldn't work. But I think I need to see it in action :)
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 08:16:48 AM
Everything you should need to run the JAPI examples is included in the zip. Just point your system path to include the ScriptBasic bin directory.

Example:

scriba graphic.bas
Title: Re: JAPI 2.0
Post by: Mopz on June 06, 2013, 09:16:48 AM
Thanks!
Title: Re: JAPI 2.0
Post by: Mopz on June 06, 2013, 12:02:15 PM
I thought I would mention that if I use the following LaF (lookAndFeel) setting for Windows, all the test programs work. Any other LaF setting breaks things. With that tidbit, what do you think is causing the breakdown with more enhanced themes? (using latest deprecation updated DLL)

swing.properties
Code: [Select]
swing.defaultlaf=com.sun.java.swing.plaf.basic

If I try that one, nothing at all shows here (the scriba process runs, but no window pops up). I've tried with
, and not specifying any laf at all (resulting in the metal look, I think). The examples behave the exact same way with these three settings. That is, many of them don't run at all, some (like the colorpicker) get hung when you try the actions, some of them show empty windows with some content flickering if I resize the windows. And some of them work as I assume they should.

Doesn't the java console work with java apps? I can have it popup every time I run an applet to see what's going on under the hood, but I can't get it running with this.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 04:41:53 PM
swing.properties
Code: [Select]
swing.defaultlaf=com.sun.java.swing.plaf.basic
This is the only LaF that allows all the examples to work. This swing.properties file must be in the lib directory of the JRE you are using. You must reboot or at least log out to have the new LaF take effect. I normally start with button.bas to indicate what theme is being used. I then try graphic.bas. With the above LaF all the primitive types display. Any other LaF only the line (upper left corner) shows. (vumeter & digits examples just hang with extended themes)

I assume scriba (ScriptBasic) and the JAPI extension module at least seem to be working.

Title: Re: JAPI 2.0
Post by: Mopz on June 06, 2013, 04:55:30 PM
ScriptBasic has always been working here :) I already realized I had to reboot between changes. Where can I find the latest japi java and c source. I haven't been paying enough attention. Were the issues present before you begun fixing the deprecations?
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 05:00:42 PM
I downloaded the source (http://userpages.uni-koblenz.de/~evol/japi/download/japilib.zip) from the JAPI site (http://www.japi.de/).

I posted to this thread the updated .java source files that had deprecation issues.

Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 05:04:45 PM
Quote
Were the issues present before you begun fixing the deprecations?

The same theme related issues remained after making the deprecation changes. The upgrade did not introduce any new issues.
Title: Re: JAPI 2.0
Post by: Mopz on June 06, 2013, 05:08:12 PM
I downloaded the source from there yesterday. But as I remember it from the java files, it was all awt based, not swing. But being drunk and all I might have missed a folder or two. I'll have another look.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 05:52:44 PM
There are two Java source directories. The binaries from the site were built using the java files. I built from and updated the swing Java source files.

Observation:

If I use the extended theme settings, I lose the ability to set background colors. (see list.bas) If I put the function that sets background color in a message loop, it works as intended. (like a clear screen with a defined color) This is why I think its something simple missing. Current theming and it's direction wasn't known back in 2003.

Title: Re: JAPI 2.0
Post by: ScriptBasic on June 06, 2013, 07:20:49 PM
Marcus,

Since this is a multi-language effort, I think it would be best to build a generic VC10 JAPI 2.0 DLL. (and post the modified .java files so variations can be built) That way others (CM) can help test. You can always use DLLC with ScriptBasic to test the generic DLL rather than the SB extension module version of JAPI 2.0.

John
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 08, 2013, 03:47:40 AM
Back to the future ...

I went back to the AWT (Java directory) version on my Ubuntu 64 laptop and all the demos are working again. No theming to speak of but that's okay. Here is the Chaos Butterfly under Linux.

(http://files.allbasic.info/ScriptBasic/chaosbutfly.png)

Code: [Select]
import japi.bas

j_start
win = j_frame("Lorenz Butterfly")
can = j_canvas(win, 640, 480)
j_pack(win)
j_show(win)

x =  0.0
y = 20.0
z = 20.0

j_setnamedcolorbg(can, J_BLACK)
while obj <> win
  xx = x + 0.01 * ( -10.0 * x + 10.0 * y)
  yy = y + 0.01 * (  28.0 * x - y - x * z )
  zz = z + 0.01 * ( -8.0  * z / 3.0  + x * y )
  j_setcolor(can, Rnd(), Rnd(), Rnd())
  j_drawline(can, x*10+320, -z*10+500, xx*10+320, -zz*10+500)
  x = xX
  y = yY
  z = zZ
  obj = j_getaction()
  j_sleep(50)
wend                         
j_quit
 
Title: Re: JAPI 2.0
Post by: DJLinux on June 08, 2013, 06:29:40 AM
... I think it would be best to build a generic VC10 JAPI 2.0 DLL ...
Hello John
i won't teach you in any direction
but I'm a old coder and can give you a tip
in scope of C/C++ for Windows and Linux systems.

Normally I use an gcc environment for all my library projects
and this are a lot in the past for FreeBASIC, thinBasic, Basic4GL, PureBasic etc.

Only for my business I must used VisualStudio from time to time.

You can install code::blocks with mingw on windows
now for example OpenB3D create a static and a dynamic lib
add all *.c and *.cpp files to your new fresh project and rebuild the lib.

Now comes the tip install code::blocks on your Linux box also.
Open the windows OpenB3D project (may be mounted as folder or via copy in your home folder)
Select or add Linux as new target in your project and rebuild.

That's all and so easy.

There are many points why an gcc environment on Windows makes sense.

If you will share your VS lib's and dll's you can research your lib with an dependency walker
and you will see your VS libs needs some more VC 8/9/10/11 run time library's  as you would except.

The same lib or dll build with gcc on windows used the RTL libs from OS (not VC).

This is why i never need an run time installer if I share my projects.

If you rebuild really large lib's IUP, ODE, True Axis, IrrLicht etc.
you will see the result of an GCC environment is often much smaller as from VS.

There are one point where VS is the first choice I mean ActiveX/Com project's
but this has nothing to do with cross compiling for Windows and Linux.

bla bla bla  ;)

Happy coding.

DJ
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 08, 2013, 07:08:38 AM
Joshy,

I couldn't agree with you more. I have MinGWTDM32 install as well and how I compile most of the JAPI build utilities. I only use VC10 for the SB extension modules as that is how all the others are built. My end goal with SB is to be gcc across the board.

You have my vote to go the MinGW route.

John
Title: Re: JAPI 2.0
Post by: DJLinux on June 08, 2013, 09:35:26 AM
I only use VC10 for the SB extension modules as that is how all the others are built. My end goal with SB is to be gcc across the board.
I was thinking you build JAPI2.dll with VC and JAPI2.so with GCC.

How ever i won't teach you
it was only a tip no stress with make files any more :lol:

DJ
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 08, 2013, 04:58:04 PM
I use MinGW gcc to build the makefiles for the Java compile and build the japiserver.h file which is the JAPI.jar in a byte array. I then use VC10 to compile the ScriptBasic JAPI extension module. If I build a generic JAPI.dll, I use gcc through the complete process.

Title: Re: JAPI 2.0
Post by: ScriptBasic on June 09, 2013, 01:16:13 AM
JAPI 2.0 News

I was able to get JAPI (AWT version) working with BaCon as a static library interface.

More ... (http://basic-converter.proboards.com/index.cgi?action=gotopost&board=code&thread=485&post=4255)

Title: Re: JAPI 2.0
Post by: Mopz on June 09, 2013, 10:01:48 AM
I've got a fat book here, written in 2001 about AWT and Swing. I'll see if I can figure out why the different LaF:s don't work. But I'm not sure I'll get anywhere with it (time ...). For my own sake, as I wrote earlier, I'm pleased enogugh with the AWT version. I'd rather spend my time on writing an AWT JAPI extension for naalaa ;)

But right now I'm making "sheperd's pie" for my oldest daughter. It's her favourit food, and she turned seven yesterday ;)
Title: Re: JAPI 2.0
Post by: Mopz on June 09, 2013, 10:13:51 AM
Quote
but I'm a old coder and can give you a tip

I think John's an even older coder :) I feel like an honoured li'l' kid among you guys.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 09, 2013, 05:58:50 PM
61 in Nov. I've been around when BASIC was the OS.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 09, 2013, 06:57:50 PM
Quote
I'm pleased enogugh with the AWT version. I'd rather spend my time on writing an AWT JAPI extension for naalaa

Maybe it would be worth doing the deprecation upgrades to the AWT version also.

Title: Re: JAPI 2.0
Post by: ScriptBasic on June 11, 2013, 04:40:48 PM
It seems the interest in JAPI has faded. I have standardized on the AWT version because I can make all the API calls work on both Windows and Linux. (32/64 bit)  Marcus seems overwhelmed with real life adventures and populating the world.  ;D

I'm going to do the deprecation upgrades to the AWT version as I don't see the swing version becoming a reality any time soon.
Title: Re: JAPI 2.0
Post by: Aurel on June 16, 2013, 10:35:19 AM
A-Men... :o
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 20, 2013, 05:52:49 AM
Marcus,

Any progress on JAPI on any front?

John
Title: Re: JAPI 2.0
Post by: Mopz on June 20, 2013, 03:39:14 PM
Nope, sorry :) My vaccation starts in two weeks, then I'll finally get some time for fun. These days it's just work, work and work.
Title: Re: JAPI 2.0
Post by: ScriptBasic on June 20, 2013, 10:20:22 PM
I might poke around on the Java forums and see if I can build any interest in JAPI. I might be wasting my time with this and should just let the project rest in peace.

Title: Re: JAPI 2.0
Post by: ScriptBasic on May 19, 2014, 12:08:30 AM
If the admin wants to close this thread I wouldn't care. I wrote a SDL_gfx based extension module for Script BASIC and have lost all interest in the JAPI environment. The B4J (BASIC for Java - from the BASIC for Android author) looks interesting.