Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

newbie Threads and JDialog

Thread view: 
Edsoncv - 15 Nov 2007 01:24 GMT
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);
        }

    }

}
Andrew Thompson - 15 Nov 2007 02:21 GMT
...
>..I'm listing in a reduced way my code:

The best way to 'reduce' code for posting to usenet is
to produce an SSCCE*.  It also helps to avoid line-wrap*
if you make sure there are no tab characters used to
indent code lines.

* <http://www.physci.org/codes/sscce.html>

** A tool to help check line width, and replace tabs
<http://www.physci.org/twc.jnlp>

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.