Author Topic: JAPI 2.0  (Read 36740 times)

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #30 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.

 

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #31 on: May 27, 2013, 06:51:13 AM »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: JAPI 2.0
« Reply #32 on: May 27, 2013, 08:05:18 AM »
Ok, now what's the secret?

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #33 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


Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: JAPI 2.0
« Reply #34 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??

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #35 on: May 27, 2013, 08:49:25 AM »


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.

« Last Edit: May 27, 2013, 08:51:41 AM by ScriptBasic »

Mopz

  • Guest
Re: JAPI 2.0
« Reply #36 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

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #37 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


Mopz

  • Guest
Re: JAPI 2.0
« Reply #38 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  :)
« Last Edit: May 27, 2013, 04:53:24 PM by Mopz »

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #39 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.


Mopz

  • Guest
Re: JAPI 2.0
« Reply #40 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().
« Last Edit: May 27, 2013, 05:33:16 PM by Mopz »

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #41 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.


Mopz

  • Guest
Re: JAPI 2.0
« Reply #42 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 :)

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #43 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

ScriptBasic

  • Guest
Re: JAPI 2.0
« Reply #44 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;
}