Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 3 Jahren, 8 Monaten
Letzter Beitrag:
vor 3 Jahren, 7 Monaten
Beteiligte Autoren:
Yogi Yang, Arie, DerekT, Ruben Sanchez Peña, Allard

Cannot enter JAVA code in WM17

Startbeitrag von Yogi Yang am 01.10.2014 14:51

In an app that I have developing I want to enter JAVA code but I am not able to find the button on event that will allow me to enter JAVA code.

How to get this feature ?


Yogi Yang



From the Help: Enter code in Java

To enter the code of a global procedure in Java:

1. Create a new global procedure (via "New global procedure" from the popup menu of the sets of procedures in the "Project explorer" pane). Specify the name of this procedure.
2. In the code editor, click the "WL" letters found in front of the caption of the global procedure. The bar becomes purple and the "Java" characters are displayed in front of the name of the procedure. The existing code is changed into comments.

von DerekT - am 01.10.2014 16:45
Hi Yogi,

Indeed just click on the wl bar. It is just like adding php code in webdev or java in windev.



von Allard - am 02.10.2014 10:28
DerekT & Allard,

This means that I have to create Global Procedures then only I will get this functionality?

I thought we get this functionality at Local Procedure level but could not find it there!


Yogi Yang

von Yogi Yang - am 02.10.2014 13:52
package and import not working in JAVA code:

I am using this code:
package com.jjoe64.graphview;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.jjoe64.graphview.*;


Yogi Yang

von Yogi Yang - am 02.10.2014 15:14

Unfortunately I have not used this functionality myself.:-(
Just something I had noticed when going through the examples.

Hopefully a Java guru will pick this one up and advise

von DerekT - am 02.10.2014 15:52

I'm missing the actual function you want to run. The above are just the imports of the librarys you are going to use IN your own function(s)

Copy this and you can call JavaInternetConnected from any place in your app.

import android.content.Context;
import android.net.ConnectivityManager;

public static boolean JavaInternetConnected() {
Context c = getApplicationContext();
ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isAvailable()
&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
//Log.v(TAG, "Internet Connection Not Present");
return false;

von Arie - am 02.10.2014 16:50

Your code compiled properly.

But I want to use a charting library called GraphView-3.1.3.jar.

If I cut and paste the code given in its sample does not get compiled and gives strand errors.

For me JAVA is an alien language as I personally dislike JAVA.


Yogi Yang

von Yogi Yang - am 03.10.2014 06:17
Hi. You can use java code in WM, but maybe you need rewrite your library sample to work from WM.

When you create a global procedures file to contain your java code, WM create a java class to encapsulate the procedures you write.

You can too include complete classes source code, but then the classes only can be used from the java procedures you write, not from your WM code.


von Ruben Sanchez Peña - am 03.10.2014 17:05
Finally! I have manged to include JAR files in WM17 projects on Integrating JAVA Libraries wizard page.

But now I am not able to pass the context of the control or window where I want to show the Chart.

Here is the code:
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.jjoe64.graphview.*;

public static boolean JavaInternetConnected() {

// init example series data
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphView.GraphViewData[] {
new GraphView.GraphViewData(1, 2.0d)
, new GraphView.GraphViewData(2, 1.5d)
, new GraphView.GraphViewData(3, 2.5d)
, new GraphView.GraphViewData(4, 1.0d)

GraphView graphView = new LineGraphView(
this // context

von Yogi Yang - am 20.10.2014 05:58

I think you need the context there. Try something like this

Context mycontext = getApplicationContext();
GraphView graphView = new LineGraphView( mycontext , "GraphViewDemo");

You need this import too
import android.content.Context;

It would be VERY interesting if you succeed. This means we can use 3-party controls?

von Arie - am 23.10.2014 20:38

Thanks for your tip. It did help solve the problem but this line

LinearLayout layout = (LinearLayout) findViewById(R.id.layout);

is giving Error :mad:

I tried to replace this with Context but in my case it still fails to compile.

One more question:
I need to show the chart in a specific location in my app so setting context of application will do the trick or have I to somehow pass context of the placeholder control (which is an image control) to this routine?

Please share your ideas.


Yogi Yang

von Yogi Yang - am 07.11.2014 14:50
did you add this import as well?
import android.view.*

I'm not a Java export though, but I played with it last year. I came across this code, which did work if I remember correctly.
So you can just pass the controls name from your WD code and use getView() instead of findViewById()

import android.view.View;
ipublic static void testjava(String sControl, boolean bVisible)
View vw1 = getView(sControl);
vw1.setVisibility(View.VISIBLE); // 0
else {
vw1.setVisibility(View.INVISIBLE); // 4

von Arie - am 07.11.2014 15:10
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.