Wiezewazoel
Programmer
Hello
I did not buy microfocus or something like it, so don't mention it!
i had to make java calling cobol, which works, but th real problem is:
I can't get it closed :s I'll explain with code...will be better:
This is the code that calls the certain cobol program
The dutch:
Cobolpoort ==> "cobolport"
naambestand ==> filename
this works perfect!
but when i try calling it after i click a button in a jDialog:
this is the button action event! "keuze" is the choice the user made in a listbox "cbbProjecten".
then there is "TijdsbestedingCobol" which is a class that has similarities of a controller class:
I have tried to put this into a thread, though it worked out of it too, but the problem is...
At the arrow in this last piece of code, "===============>", there I have to put the dialog which calls this method, on invisible
ELSE i can NOT type in my cobol application!
my conclusion is, because its called after a dialog, or frame, it will keep doing weird.
In case you wondered how my cobol program finishes and begins:
So my question is, anyone has an idea how to fix this?
- So i can push the button, java gives trough a parameter, my cobol program loads, asks things, etc, gives back something, displays it back in the dialog without seeing the cobol program ofcourse
things in blue work, things in red don't
I did not buy microfocus or something like it, so don't mention it!
i had to make java calling cobol, which works, but th real problem is:
I can't get it closed :s I'll explain with code...will be better:
Code:
import com.legacyj.api.Callable;
public class CobolPoort
{
private Callable theCom;
public CobolPoort (String naamBestand)
{
try
{
Class<Callable> prog;
prog = (Class<Callable>) Class.forName(naamBestand);
theCom = prog.newInstance();
}
catch (Throwable e)
{
e.printStackTrace();
}
}
public Object uitvoeren (boolean[] booleans, Object[] objects)
{
try
{
return theCom.call(booleans, objects);
}
catch (Throwable e)
{
e.printStackTrace();
return null;
}
}
}
This is the code that calls the certain cobol program
The dutch:
Cobolpoort ==> "cobolport"
naambestand ==> filename
I do not have a single problem when i call this from a class where it is in the main Example:
Code:
package gui;
import cobolLink.CobolPoort;
public class NewTest
{
public static void main(String[] args)
{
int i = 0;
CobolPoort poort = new CobolPoort("duurtijdproject");
Object[] params = new Object[]{new Integer(1)};
boolean[] booleans = new boolean[]{false};
Object res = poort.uitvoeren(booleans, params);
String alles = res.toString();
double tijd = Double.parseDouble(alles.substring(0, 6));
int teller = Integer.parseInt(alles.substring(6, 11));
System.out.println("Duur: " + tijd);
System.out.println("Teller: " + teller);
if(teller!=0)
do
{
String activiteit = alles.substring((11 + i) + (i*10), (22+i) + (i*10));
int activiteitID = Integer.parseInt(activiteit.substring(0,5));
double duur = Double.parseDouble(activiteit.substring(5,11));
System.out.println("ActiviteitID: " + activiteitID + " heeft een duur van " + duur);
i++;
}while(i<teller);
}
}
this works perfect!
but when i try calling it after i click a button in a jDialog:
Code:
private void btnToonActionPerformed(ActionEvent evt)
{
int keuze = TijdsbestedingCobol.getID(cbbProjecten.getSelectedItem().toString());
txtpUitvoer.setText(TijdsbestedingCobol.uitvoeren(this,keuze));
}
this is the button action event! "keuze" is the choice the user made in a listbox "cbbProjecten".
then there is "TijdsbestedingCobol" which is a class that has similarities of a controller class:
Code:
package domein;
import javax.swing.JDialog;
import persistentie.Sql;
import cobolLink.CobolPoort;
public class TijdsbestedingCobol
{
private static Sql sql = new Sql();
private static StringBuffer resultaat = new StringBuffer();
public static String[] getProjecten()
{
return sql.getProjecten();
}
public static int getID(String project)
{
return sql.getID(project, 1);
}
public static String uitvoeren(JDialog cobol, int projectnr)
{
[red]===============>[/red]cobol.setVisible(false);
TijdsbestedingCobol tijds = new TijdsbestedingCobol();
TijdsbestedingCobol.CobolThread c = tijds.new CobolThread(projectnr);
new Thread(c).start();
return resultaat.toString();
}
class CobolThread extends Thread {
int projectnr;
CobolThread(int projectnr)
{
this.projectnr = projectnr;
}
public void run()
{
int i = 0;
CobolPoort poort = new CobolPoort("duurtijdproject");
Object[] params = new Object[]{new Integer(1)};
boolean[] booleans = new boolean[]{false};
Object res = poort.uitvoeren(booleans, params);
String alles = res.toString();
double tijd = Double.parseDouble(alles.substring(0, 6));
int teller = Integer.parseInt(alles.substring(6, 11));
if(teller!=0)
{
do
{
String activiteit = alles.substring((11 + i) + (i*10), (22+i) + (i*10));
int activiteitID = Integer.parseInt(activiteit.substring(0,5));
double duur = Double.parseDouble(activiteit.substring(5,11));
resultaat.append("ActiviteitID: " + activiteitID + " heeft een duur van " + duur + "\n");
i++;
}while(i<teller);
}
else
{
resultaat.append("De totale duurtijd van dit project is: " + tijd);
}
}
}
}
I have tried to put this into a thread, though it worked out of it too, but the problem is...
At the arrow in this last piece of code, "===============>", there I have to put the dialog which calls this method, on invisible
ELSE i can NOT type in my cobol application!
my conclusion is, because its called after a dialog, or frame, it will keep doing weird.
In case you wondered how my cobol program finishes and begins:
Code:
PROCEDURE DIVISION USING projectnr GIVING Group-Data.
MAIN-PARAGRAPH.
...
/ ==> The user gets a question if he wants to give the values back to Java or not!
If yes
Exit program
If no
Stop run
So my question is, anyone has an idea how to fix this?
- So i can push the button, java gives trough a parameter, my cobol program loads, asks things, etc, gives back something, displays it back in the dialog without seeing the cobol program ofcourse
things in blue work, things in red don't