Access already running objects - Java
<pre><code>   import java.awt.*;

   import javax.swing.*;
   import javax.swing.table.DefaultTableCellRenderer;
   import javax.swing.table.TableColumn;


   public class vasilisTable extends JFrame {

    Object[] split_data_l; 
    Object[][] split_data;
    Object [][] split_data_clone;
    Object [][] split_data_reverse;
    Object [][] split_data_reverse_num;
    String[] temp;
    private JTable table;
    private JPanel bottom_panel;
    private JLabel average;
    private JLabel max_dr;

    public vasilisTable(String name, String data, int choice)
    {
        super(name);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //the DISPOSE_ON_CLOSE    means that when we press the x button is will close only the table window and not the whole    programm
        //this.getAccessibleContext().setAccessibleName(name);
        //System.out.println(this.getAccessibleContext().getAccessibleName());
        setSize(800,600);



        String[] columnNames = {"Date", "Open","High","Low","Close",
                 "Volume", "Adjusted" };//defines the column names


        //------ Start of making the arrays that will be used as data for the table creation

        split_data_l = data.split( "\n" );
        int lngth = split_data_l.length;
        split_data = new Object[lngth-1][7];
        split_data_clone = new Object[lngth-1][7];
        split_data_reverse= new Object[lngth-1][7];
        split_data_reverse_num= new Object[lngth-1][7];
        double sum = 0;

        for(int k=1; k&lt;split_data_l.length; k++) //initializing the three arrays with the data we got from the URLReader 
        {
            temp = split_data_l[k].toString().split(",");
            for (int l=0; l&lt;temp.length; l++)
            {
                split_data[k-1][l] = temp[l];
                split_data_clone[k-1][l] = temp[l];
                split_data_reverse[k-1][l] = temp[l];
                split_data_reverse_num[k-1][l] = temp[l];
            }
        }



        for(int k=split_data_l.length-2; k&gt;=1; k--) // making of the clone array that contains all the last column with colours
        {
            Double temp = Double.parseDouble(split_data[k][6].toString());
            Double temp1  = Double.parseDouble(split_data[k-1][6].toString());
            double check =temp-temp1;           

            if (check&gt;0)
            {
                String color_temp = "&lt;html&gt;&lt;span style = 'color:red'&gt;" + split_data_clone[k-1][6] +"&lt;/span&gt;&lt;/html&gt;" ;
                split_data_clone[k-1][6] = color_temp;
            }
            else
            {
                String color_temp = "&lt;html&gt;&lt;span style = 'color:green'&gt;" +split_data_clone[k-1][6]+"&lt;/span&gt;&lt;/html&gt;" ;
                split_data_clone[k-1][6] = color_temp;
            }

        }

        int l = split_data_clone.length;
        int m = l-1;

        for (int i=0; i&lt;l; i++) //making of the reversed array
        {
            for (int j = 0; j&lt;=6; j++)
            {
                split_data_reverse[i][j]=split_data_clone[m][j];
            }
            m--;
        }

        m = l-1;

        for (int i=0; i&lt;l; i++) //making of the reversed array
        {
            for (int j = 0; j&lt;=6; j++)
            {
                split_data_reverse_num[i][j]=split_data[m][j];
            }
            m--;
        }





        //------ End of making the arrays that will be used as data for the table creation


      //------ Start of calculating the average
        for (int i=0; i&lt;lngth-1; i++)
        {
            Double temp = Double.parseDouble(split_data[i][6].toString());
            sum = sum+temp;
            //System.out.println("turn "+i+" = "+split_data[i][6]);
        }

        float avg = (float) (sum/(lngth-1));
        avg = Round((float) avg,2);
        String avg_str;
        avg_str = "&lt;html&gt;Average: &lt;b&gt;"+avg+"&lt;/b&gt;&lt;/html&gt;";
        //"&lt;html&gt;&lt;b&gt;Average: &lt;/b&gt;&lt;/html&gt;"



      //------ End of calculating the average


      //------ Start of Calculating the Maximal Drawdown

        double high=0;
        double low=100000000;
        double drawdown=0;
        double max_drawdown=0;
        int last_high=0;
        int last_low=0;

        for (int i=0; i&lt;lngth-1; i++)
        {
            Double temp = Double.parseDouble(split_data_reverse_num[i][6].toString());
            //Double temp1 = Double.parseDouble(split_data[i+1][6].toString());

            if (temp&gt;high)
            {
                high = temp;
                last_high = i;
                //System.out.println("max high = "+temp);
            }
            else
            {
                low = temp;
                last_low = i;
                //System.out.println("max low = "+temp);
            }
            if (last_low&gt;last_high)
            {
                drawdown = high-low;
                //System.out.println("drawdown = "+drawdown);

            }
            if (drawdown&gt;max_drawdown)
            {
                max_drawdown = drawdown;
            }
        } 

        //System.out.println("max dr = "+max_drawdown);
        String max_dr_str = "&lt;html&gt;Maximal Drawdown: &lt;b&gt;"+max_drawdown+"&lt;/b&gt;&lt;/html&gt;";


      //------ End of Calculating the Maximal Drawdown



        average = new JLabel(avg_str);
        max_dr = new JLabel(max_dr_str);
        bottom_panel = new JPanel();
        String space = "       ";
        JLabel space_lbl = new JLabel(space);
        bottom_panel.add(average);
        bottom_panel.add(space_lbl);
        bottom_panel.add(max_dr);

        //-------- Start of table creation ---------

        if(choice==1)
        {
            table = new JTable(split_data_clone, columnNames);//creates an instance of the table with chronological order
        }else
        {
            table = new JTable(split_data_reverse, columnNames);//creates an instance of the table with reverse chronological order
        }

        TableColumn column = null;
        for (int i = 0; i &lt; 7; i++) {
            column = table.getColumnModel().getColumn(i);
            if (i == 0) {
                column.setPreferredWidth(100); //third column is bigger
            } else if (i == 5) {
                column.setPreferredWidth(85); //third column is bigger
            }
            else if (i == 6) {
                column.setPreferredWidth(70); //third column is bigger
            }
            else {
                column.setPreferredWidth(50);
            }
        }
        table.setShowGrid(true);
        table.setGridColor(Color.black);

        //-------- End of table creation ---------







        JPanel table_panel = new JPanel (new BorderLayout());       
        JScrollPane table_container = new JScrollPane(table); // create a container where we will put the table
        //table.setFillsViewportHeight(true); // if the information are not enough it still fill the rest of the screen with cells

        table_panel.add(table_container, BorderLayout.CENTER);
        table_panel.add(bottom_panel, BorderLayout.SOUTH);
        //table_panel.add();

        setContentPane (table_panel);

        pack(); // here i pack the final result to decrease its dimensions


    }

    public float Round(float Rval, int Rpl) // this functions rounds the number to 2 decimal points
    {
    float p = (float)Math.pow(10,Rpl);
    Rval = Rval * p;
    float tmp = Math.round(Rval);
    return (float)tmp/p;
    }   


}
</code></pre>

<p>I am making an application which creates various instances of a class. These instances are actually some windows. After having create multiple of these windows, how can I access one of them and bring it in front? I know the .tofront() method, but how can I specify the window that I want to bring in front?</p>

<p>Above is the code that creates every window. My main problem is that after I have create e.g 5 windows, how can I access one of them?</p>

<p>ps </p>

<p>code that creates each window:</p>

<pre><code>  if (sData != null) {
                    //System.out.println("Success, waiting response");

                    vasilisTable ftable = new vasilisTable(name, sData, choice);
                     hashMap.put(name, ftable);
                    ftable.setVisible(true);

                    //choice=2;

                  }    
</code></pre>
