How to send one variable from one class to another for gui purpose?

387 Views Asked by At

I am using Eclipse/Java 7. I have a class, which gets some values from queries and saves them in the 2 dimensional array path. Then I have made another class which designs 2 linked blocks. What I want to do is get the values of path1[0] and path[2][0] etc from the first class and automatically place them in the designed blocks. Any ideas how to do it? Thanks in advance

Example enter image description here

1st class (results from queries):

public class OntoQ extends JFrame {

    public static void main(String[] args) {


    String[][] path = new String[20][2];
    int pathi = 0;
    int pathj = 0;
....

2nd class (design):

import javax.swing.JFrame;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;


public class Design extends JFrame {

    public Design() {


        super("Test");



        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();


        graph.getModel().beginUpdate();
        try
        {
            Object v1 = graph.insertVertex(parent, null, "path[1][0]", 20, 20, 80,
                    30);
            Object v2 = graph.insertVertex(parent, null, "path[2][0]" , 240, 150,
                    80, 30);
            graph.insertEdge(parent, null, "Edge", v1, v2);
        }
        finally
        {
            graph.getModel().endUpdate();
        }

        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        add(graphComponent);


    }


    public static void main(String[] args)
    {
        Design frame = new Design();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 320);
        frame.setVisible(true);
    }

}
0

There are 0 best solutions below