ArrayIndexOutOfBoundsException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #16
    Code:
    testcomm.TestForm.startTimer() ;
    You are trying to call a .startTimer() method from the TestForm class, but it should be called from a Timer. Try

    Code:
    testcomm.TestForm.mainTmr.startTimer();
    or just

    Code:
    mainTmr.startTimer();

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #17
      Originally posted by ivannavi
      and second:
      Code:
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(jLabel1)
      .addComponent(jLabel2)
      .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addGroup(layout.createSequentialGroup()
      .addComponent(jButton6)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
      .addContainerGap())
      );
      pack();
      }// </editor-fold> 
       
      private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { 
       
      timeSample = jComboBox1.getSelectedItem().toString();
      timeSampleLong= Long.parseLong(timeSample);
      } 
       
      private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { 
      String ZelTemp = ReadParamFromPIC('W');
      String Histereza = ReadParamFromPIC('H');
      String CritTemp = ReadParamFromPIC('C');
       
      jTextField3.setText(ZelTemp);
      jTextField4.setText(Histereza);
      jTextField5.setText(CritTemp);
      } 
       
      private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { 
      // if(mainTmr != null)
      // mainTmr.cancel(); 
      Setting Stng = new Setting();
      Stng.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ;
      Stng.setLocation ( 300 , 300 ) ;
      Stng.setVisible ( true ) ;
      } 
       
      private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { 
      mainTmr.cancel();
      } 
       
      private void formWindowActivated(java.awt.event.WindowEvent evt) { 
      // TODO add your handling code here:
      } 
      private void DrawGraph()
      {
      dataset = createDataset();
      TCh = new TChartWrite();
      MainChrt = TCh.createChart(dataset);
      MainChartPnl = new ChartPanel(MainChrt);
      MainChartPnl.setBounds(0,0,640,480);
      jPanel1.add(MainChartPnl);
      jPanel1.setVisible( true );
      MainChartPnl.validate();
      tseries = dataset.getSeries(0);
      }
      private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { 
      // TODO add your handling code here:
      startTimer();
      } 
       
      //Branje in pisanje ComPorta!
      public String ReadParamFromPIC(char ParamIn)
      {
      GenBuffCnt = 0;
      Comm.PutData((byte)ParamIn);
      if(GenBuffCnt > 5)
      {
      GenBuffCnt = 0;
      return null;
      }
      while(GenBuffCnt!=5);
      byte [] WriteBuff = ReturnNewBytes(GenBuffer);
      String Data = new String(WriteBuff,0,4); 
      GenBuffCnt = 0;
      return Data;
      }
      public static void WriteParamToPic(String ParamIn)
      {
      char [] WriteParam = new char[4]; 
      WriteParam =ParamIn.toCharArray();
      for(int i=0; i<4; i++){ 
      Comm.PutData((byte) WriteParam[i]) ;
      try {
      Thread.sleep (3);
      }
      catch ( Exception ex ) {
      ex.printStackTrace();
      }
      }
       
      }
      private void ReadTemperatureFromRS232()
      {
      String Data = ReadParamFromPIC('R');
      jTextField1.setText(Data);
      GenCount++;
      jTextField2.setText(Integer.toString(GenCount));
      float Dat = Float.parseFloat(Data);
      tseries.addOrUpdate(new Second(new Date()),Dat);
      }
      private byte [] ReturnNewBytes(byte [] DataIn)
      {
      byte [] DataOut = new byte[5];
      DataOut[0] = DataIn[1];
      DataOut[1] = DataIn[2];
      DataOut[2] = '.';
      DataOut[3] = DataIn[4];
       
      return DataOut;
      }
      public static void startTimer() 
      {
      	mainTmr = new Timer();
      mainTmr.schedule((new TimerChhRunCls()),1000,timeSampleLong);
      }
      class TimerChhRunCls extends TimerTask 
      {
      public void run() 
      {
      ReadTemperatureFromRS232();
      }
       
      }
       
      class TimerTestRun extends TimerTask 
      {
      public void run() 
      {
      UpdateBoxAndGraph();
      }
       
      }
      private void UpdateBoxAndGraph()
      {
      GenCount++;
      jTextField2.setText(Integer.toString(GenCount));
      float Dat = Float.parseFloat("13.4");
      Dat = Dat + GenCount;
      tseries.addOrUpdate(new Second(new Date()),Dat);
       
       
      }
      private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
       
      try
      {
      	 Comm = new TwoWaySerialComm();
      Comm.connect(ComPort);
      	 }
      	 catch ( Exception e )
      	 {
       
      	 e.printStackTrace();
      	 }
       
      } 
      private TimeSeriesCollection createDataset() 
      {
      TimeSeries ts = new TimeSeries("T", Second.class);
      TimeSeriesCollection dataset = new TimeSeriesCollection();
      dataset.addSeries(ts);
      ts.setMaximumItemAge(30*60);
      return dataset;
      }
       
      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new TestForm().setVisible(true);
      }
      });
      }
       
      // Variables declaration - do not modify 
      private javax.swing.JButton jButton1;
      private javax.swing.JButton jButton2;
      private javax.swing.JButton jButton4;
      private javax.swing.JButton jButton5;
      private javax.swing.JButton jButton6;
      private javax.swing.JComboBox jComboBox1;
      private javax.swing.JFrame jFrame1;
      private javax.swing.JLabel jLabel1;
      private javax.swing.JLabel jLabel2;
      private javax.swing.JPanel jPanel1;
      public static javax.swing.JTextField jTextField1;
      private javax.swing.JTextField jTextField2;
      private javax.swing.JTextField jTextField3;
      private javax.swing.JTextField jTextField4;
      private javax.swing.JTextField jTextField5;
      // End of variables declaration 
       
       
      }
      No that cannot be the line with the error this time. Check again with both startTimer and timeSampleLong declared as static and check the line number for the error and error method.

      I have to go in about 30mins or so, so please try to respond soon.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #18
        Originally posted by Ganon11
        Code:
        testcomm.TestForm.startTimer() ;
        You are trying to call a .startTimer() method from the TestForm class, but it should be called from a Timer. Try

        Code:
        testcomm.TestForm.mainTmr.startTimer();
        or just

        Code:
        mainTmr.startTimer();
        Yes. Try this with both startTimer and timeSampleLong declared as non-static.

        Comment

        • ivannavi
          New Member
          • Jan 2007
          • 24

          #19
          Now this appeares:
          cannot find symbol.
          symbol: metod startTimer()
          location: class java.util.Timer
          when i go with mouse on the error line:
          testcomm.TestFo rm.mainTmr.star tTimer();

          and when i write "." after:
          testcomm.TestFo rm.mainTmr
          there are no startTimer metod to choise it.

          If i try with:
          mainTimer.start Timer();
          it look after only in Setting class


          I'm sending class Setting; it's another JFrame from where am i maneging parameters

          Code:
          package testcomm;
          
          public class Setting extends javax.swing.JFrame {
              
              /** Creates new form Setting */
              public Setting() {
                  initComponents();
              }
              
              
              // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
              private void initComponents() {
                  jLabel1 = new javax.swing.JLabel();
                  jComboBox1 = new javax.swing.JComboBox();
                  jLabel2 = new javax.swing.JLabel();
                  jComboBox2 = new javax.swing.JComboBox();
                  jLabel3 = new javax.swing.JLabel();
                  jComboBox3 = new javax.swing.JComboBox();
                  jButton1 = new javax.swing.JButton();
          
                  setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                  getAccessibleContext().setAccessibleName("Params");
                  jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jLabel1.setText("Zeljena Temperatura");
          
                  jComboBox1.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "213", "251", "302" }));
          
                  jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jLabel2.setText("Dov. Odstopanje");
          
                  jComboBox2.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "002", "003", "005", "008", "001" }));
          
                  jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jLabel3.setText("Kriti\u010dna Temperatura");
          
                  jComboBox3.setFont(new java.awt.Font("Tahoma", 0, 14));
                  jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "400", "450", "500" }));
          
                  jButton1.setText("Set Parameters");
                  jButton1.addActionListener(new java.awt.event.ActionListener() {
                      public void actionPerformed(java.awt.event.ActionEvent evt) {
                          jButton1ActionPerformed(evt);
                      }
                  });
          
                  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                  getContentPane().setLayout(layout);
                  layout.setHorizontalGroup(
                      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(layout.createSequentialGroup()
                          .addGap(33, 33, 33)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                              .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                              .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                              .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                              .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                              .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                              .addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                              .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                          .addContainerGap(45, Short.MAX_VALUE))
                  );
                  layout.setVerticalGroup(
                      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(layout.createSequentialGroup()
                          .addGap(27, 27, 27)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addComponent(jLabel3)
                              .addComponent(jLabel2)
                              .addGroup(layout.createSequentialGroup()
                                  .addComponent(jLabel1)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                      .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                                      .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                                      .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))))
                          .addGap(26, 26, 26)
                          .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addContainerGap(25, Short.MAX_VALUE))
                  );
                  pack();
              }// </editor-fold>                        
          
              private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
                  
                  String ZelTemp = jComboBox1.getSelectedItem().toString();
                  String HistTemp = jComboBox2.getSelectedItem().toString();
                  String KritTemp = jComboBox3.getSelectedItem().toString();
                  
                  if(testcomm.TestForm.mainTmr != null)
                     testcomm.TestForm.mainTmr.cancel();      
          
                  testcomm.TestForm.WriteParamToPic("w"+ZelTemp);
                 try {
                        Thread.sleep (15);
                        }
                    catch ( Exception ex ) {
                               ex.printStackTrace();
                         }
                 testcomm.TestForm.WriteParamToPic("h"+HistTemp);
                 try {
                        Thread.sleep (15);
                        }
                    catch ( Exception ex ) {
                               ex.printStackTrace();
                         }
                 testcomm.TestForm.WriteParamToPic("c"+KritTemp);
                 
                testcomm.TestForm.mainTmr.startTimer();
                  // non static metod cannot be referenced from static contrxt
              }                                        
              
            
              public static void main(String args[]) {
                  java.awt.EventQueue.invokeLater(new Runnable() {
                      public void run() {
                          new Setting().setVisible(true);
                      }
                  });
              }
              
              // Variables declaration - do not modify                     
              private javax.swing.JButton jButton1;
              private javax.swing.JComboBox jComboBox1;
              private javax.swing.JComboBox jComboBox2;
              private javax.swing.JComboBox jComboBox3;
              private javax.swing.JLabel jLabel1;
              private javax.swing.JLabel jLabel2;
              private javax.swing.JLabel jLabel3;
              // End of variables declaration                   
              
          }

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #20
            Originally posted by ivannavi
            Now this appeares:
            cannot find symbol.
            symbol: metod startTimer()
            location: class java.util.Timer
            when i go with mouse on the error line:
            testcomm.TestFo rm.mainTmr.star tTimer();

            and when i write "." after:
            testcomm.TestFo rm.mainTmr
            there are no startTimer metod to choise it.

            If i try with:
            mainTimer.start Timer();
            it look after only in Setting class


            I'm sending class Setting; it's another JFrame from where am i maneging parameters

            Code:
            package testcomm;
             
            public class Setting extends javax.swing.JFrame {
             
            /** Creates new form Setting */
            public Setting() {
            initComponents();
            }
             
             
            // <editor-fold defaultstate="collapsed" desc=" Generated Code "> 
            private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jComboBox1 = new javax.swing.JComboBox();
            jLabel2 = new javax.swing.JLabel();
            jComboBox2 = new javax.swing.JComboBox();
            jLabel3 = new javax.swing.JLabel();
            jComboBox3 = new javax.swing.JComboBox();
            jButton1 = new javax.swing.JButton();
             
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getAccessibleContext().setAccessibleName("Params");
            jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
            jLabel1.setText("Zeljena Temperatura");
             
            jComboBox1.setFont(new java.awt.Font("Tahoma", 0, 14));
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "213", "251", "302" }));
             
            jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
            jLabel2.setText("Dov. Odstopanje");
             
            jComboBox2.setFont(new java.awt.Font("Tahoma", 0, 14));
            jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "002", "003", "005", "008", "001" }));
             
            jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14));
            jLabel3.setText("Kriti\u010dna Temperatura");
             
            jComboBox3.setFont(new java.awt.Font("Tahoma", 0, 14));
            jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "400", "450", "500" }));
             
            jButton1.setText("Set Parameters");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
            }
            });
             
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
            .addGap(33, 33, 33)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
            .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
            .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
            .addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap(45, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
            .addGap(27, 27, 27)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel3)
            .addComponent(jLabel2)
            .addGroup(layout.createSequentialGroup()
            .addComponent(jLabel1)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addGap(26, 26, 26)
            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(25, Short.MAX_VALUE))
            );
            pack();
            }// </editor-fold> 
             
            private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
             
            String ZelTemp = jComboBox1.getSelectedItem().toString();
            String HistTemp = jComboBox2.getSelectedItem().toString();
            String KritTemp = jComboBox3.getSelectedItem().toString();
             
            if(testcomm.TestForm.mainTmr != null)
            testcomm.TestForm.mainTmr.cancel(); 
             
            testcomm.TestForm.WriteParamToPic("w"+ZelTemp);
            try {
            Thread.sleep (15);
            }
            catch ( Exception ex ) {
            ex.printStackTrace();
            }
            testcomm.TestForm.WriteParamToPic("h"+HistTemp);
            try {
            Thread.sleep (15);
            }
            catch ( Exception ex ) {
            ex.printStackTrace();
            }
            testcomm.TestForm.WriteParamToPic("c"+KritTemp);
             
            testcomm.TestForm.mainTmr.startTimer();
            // non static metod cannot be referenced from static contrxt
            } 
             
             
            public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            new Setting().setVisible(true);
            }
            });
            }
             
            // Variables declaration - do not modify 
            private javax.swing.JButton jButton1;
            private javax.swing.JComboBox jComboBox1;
            private javax.swing.JComboBox jComboBox2;
            private javax.swing.JComboBox jComboBox3;
            private javax.swing.JLabel jLabel1;
            private javax.swing.JLabel jLabel2;
            private javax.swing.JLabel jLabel3;
            // End of variables declaration 
             
            }
            Ok then. I think we should get it back to having the timer as static. Make the neccessary adjustments to get it back to static and post the error that you are getting. It should be easier now that we have much of the code posted.

            Comment

            • ivannavi
              New Member
              • Jan 2007
              • 24

              #21
              Code:
              public static void  startTimer() 
                  {
              	mainTmr = new Timer();
                      mainTmr.schedule((new TimerChhRunCls()),1000,timeSampleLong);
                  }

              i got next error:

              non-static variable this cannot be refereced from a static context

              and it refers for the las line of code.

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #22
                Originally posted by ivannavi
                Code:
                public static void startTimer() 
                {
                	mainTmr = new Timer();
                mainTmr.schedule((new TimerChhRunCls()),1000,timeSampleLong);
                }

                i got next error:

                non-static variable this cannot be refereced from a static context

                and it refers for the las line of code.
                But you did not use the variable this, in that method. Are you sure the error refers to that method? Which line does it specifically say has this error?

                Comment

                • ivannavi
                  New Member
                  • Jan 2007
                  • 24

                  #23
                  it's looks that it refers refers to the method TimerChhRunCls
                  because when i change it to static the error disappears.

                  but then i have to change other "things" to static; and so on until i get to the JTextField2, which can't be changed.

                  So i decided to move all from second class to first.
                  In that way i hope will exclude this problem.

                  Am working on it now. And in this way i think that it would be even beater.
                  I have to finish it today because tomorrow i plane to work on text of my thesis.

                  Probably lately i'll have to fix other things. I have in plan just another thing do do.
                  To make text of one variable (temperature) been visible near icon Java in task bar.

                  Thank you again.

                  Comment

                  • ivannavi
                    New Member
                    • Jan 2007
                    • 24

                    #24
                    For drawing of graph am reading data at specified time drove by timer.
                    So if i wont to communicate with microcontroler i have to stop timer and then i may read or write value of new parameters and then activate timer again.

                    I may stop timer but it doesn't mean that i have stop reading data for writing graph and if am trying to deal with parameters system goes in tilt.

                    I don't wont to complicate with parallel treads.
                    So if it it could be done in way to activate some flag when graph transmission is active, and make parameter transmission to control that flag. And wit of deactivation of the flag to proceed of parameter transmission.

                    Something like this:

                    a =1
                    read data for graph
                    a=0


                    do while( a=1){
                    wait
                    }
                    write or read parameters

                    Comment

                    • ivannavi
                      New Member
                      • Jan 2007
                      • 24

                      #25
                      I'll continue to work on my application until it well be as i like it.


                      I have connected the variable of measured temperature to title of JFrame..
                      So i me see the value of temperature into taskbar near the Java icon.
                      Maybe the resolution for next problem isn't so complicate.
                      Hove can i make the title of JFrame to be seen only in taskbar line and not as a title of JFrame window?

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #26
                        Originally posted by ivannavi
                        I'll continue to work on my application until it well be as i like it.


                        I have connected the variable of measured temperature to title of JFrame..
                        So i me see the value of temperature into taskbar near the Java icon.
                        Maybe the resolution for next problem isn't so complicate.
                        Hove can i make the title of JFrame to be seen only in taskbar line and not as a title of JFrame window?
                        Strange requirement and interesting problem too. I'm not sure if it can be solved. stIconImage will set an image to be displayed on the title bar when minimized (depends on the platform). If you can somehow get your temperature into an image that would be it but probably not worth the work required for that.

                        Comment

                        • ivannavi
                          New Member
                          • Jan 2007
                          • 24

                          #27
                          Maybe it is more simple
                          to find out have it can be made that title of the frame is visible only when frame is minimized.

                          Comment

                          • r035198x
                            MVP
                            • Sep 2006
                            • 13225

                            #28
                            Originally posted by ivannavi
                            Maybe it is more simple
                            to find out have it can be made that title of the frame is visible only when frame is minimized.
                            Yes this should be possible. Just look up the event for minimised I think it's windowIconified . Would then have to call repaint so the change is reflected and after that call setVisible(fals e) to minimize it.

                            Comment

                            • ivannavi
                              New Member
                              • Jan 2007
                              • 24

                              #29
                              I was not able to use repaint and setVisible(fals e).

                              But from yours suggestion to use windowIconified
                              I had got to the next funny code(which also works):


                              Code:
                                 a=1; // for initialization (first time)
                              private void formWindowStateChanged(java.awt.event.WindowEvent evt) {                                        
                              if (a==1){
                                  setTitle("hallo");
                                  a=0;
                                     }
                              else{
                                  setTitle("");
                                   a=1;
                              }

                              And laity (because I felt that it must be some way)I found out formWindowDeico nified and the problem was resolved :
                              Thank you

                              Code:
                                  private void formWindowIconified(java.awt.event.WindowEvent evt) {                                     
                              setTitle("hallo");
                                  }                                    
                              
                                  private void formWindowDeiconified(java.awt.event.WindowEvent evt) {                                       
                              setTitle("");
                                  }

                              Comment

                              • r035198x
                                MVP
                                • Sep 2006
                                • 13225

                                #30
                                Originally posted by ivannavi
                                I was not able to use repaint and setVisible(fals e).

                                But from yours suggestion to use windowIconified
                                I had got to the next funny code(which also works):


                                Code:
                                a=1; // for initialization (first time)
                                private void formWindowStateChanged(java.awt.event.WindowEvent evt) { 
                                if (a==1){
                                setTitle("hallo");
                                a=0;
                                }
                                else{
                                setTitle("");
                                a=1;
                                }

                                And laity (because I felt that it must be some way)I found out formWindowDeico nified and the problem was resolved :
                                Thank you

                                Code:
                                private void formWindowIconified(java.awt.event.WindowEvent evt) { 
                                setTitle("hallo");
                                } 
                                 
                                private void formWindowDeiconified(java.awt.event.WindowEvent evt) { 
                                setTitle("");
                                }

                                Good work! You'll surely become a very good Java programmer if you keep at it.

                                Comment

                                Working...