newbie Threads and JDialog

E

Edsoncv

Hello all
I've been working with Java for one year and I'm a newbie with
threads, I have the following problem which I suppose you experts can
help:


I have a JDialog extension which I create some JTabbedPane with
some tables. This JDialog and these tables, send data to other class
which performs some calculation. Now I have a problem and I suspect
that its related with threads.
The button actionPerformed listener call a JDialog method that send
data and also "tells" the table to send its data to the calculation
class. After the table send the data, the constructor of the external
calculation programm fails. I'm listing in a reduced way my code:


In the Main (just the part related with the JDialog)
// in the declaratins:
public InputsIntegrationDialog inputIntDiag;
..
..
..
if (operationIndex == INTEGRATION){
if(inputIntDiag == null){
inputIntDiag = new InputsIntegrationDialog(this, getGraph());

}
else
inputIntDiag.setVisible(true);

The InputsIntegrationDialog class resumed:

public class InputsIntegrationDialog extends JDialog implements
ActionListener{
public InputsIntegrationDialog(Window owner, VRGraph grap1) {
super();
this.tabbedPane = new JTabbedPane();
fixedCostsTable = new IntegrationTable();
variableCostsTable = new IntegrationTable();

variableCosts = makeTextPanel(res.getString("variableCosts"));
tabbedPane.addTab("variableCosts",variableCostsTable );

Box okCancel = Box.createHorizontalBox();

ok = new JButton(res.getString("Ok"));
ok.addActionListener(this);
runBut = new JButton(res.getString("Run"));
runBut.addActionListener(this);
.. ..// box layouts etc...


Container contentPane = getContentPane();
contentPane.add(tabbedPane, BorderLayout.CENTER);
contentPane.add(vertBox, BorderLayout.PAGE_END);
this.pack();
this.setVisible(true);
}

public void runOPT(){
// initialize the calculation class (hiden)

//send the data from the tables to the calculation

variableCostsTable.sendDataToOpt(data 1, data 2);
// in the line bellow the problem happens!!!!!!!!!!

solver1.setNLP(nlp1.getNLP());
}
public void actionPerformed(ActionEvent e){

System.out.println("Action: " + e.getActionCommand().toString() );
if(e.getActionCommand().toString() == "Ok"){
this.setVisible(false);
}
else if(e.getActionCommand().toString() == "Run"){
// This Line calls runOpt() and inside runOPt the crashes happen
int res = this.runOpt();
if( res1 >= 0){
JOptionPane.showMessageDialog(this,
"Optimization sucessful","Message");
}
else
JOptionPane.showMessageDialog(this,
"Optimization NOT sucessful","Error");

this.setVisible(false);
}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top