?
Solved

reading from a jtable to a textArea

Posted on 2005-03-14
16
Medium Priority
?
341 Views
Last Modified: 2010-03-31
i am stuck i will like to read from cell from a jtable to a text area then read from two rows from a jtable to another textArea.  
0
Comment
Question by:mnninrod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 4
16 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13539075
textArea.setText((String)table.getModel().getValueAt(rowIndex, columnIndex));
0
 
LVL 92

Expert Comment

by:objects
ID: 13539143
for (int i=row1; i<=row2; i++)
{
   for (int j=0; j<table.getColumnCount(); j++)
   {
      ta.append(table.getValueAt(i, j)+" ");
   }
   ta.append("\n");
}
0
 
LVL 92

Expert Comment

by:objects
ID: 13539152
where row1 and row2 are the range of rows you want to display.
you can change the 2nd loop in a similiar way if you want to limit the column range.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mnninrod
ID: 13547997
i am having a problem from reading from a jtable to the textfield area. when the start button which is jbutton2 is pressed it should copy the value 0 from the jtable to  jtextfield5 the value from jtextfield5 to jtextfield7. copy the value 01999 from the jtable to jtextfield2 and copy the value from jtextfield2 to jtextfield6 and increment the value in jtextfied5 by 1.
when using cehj comment i am getting a java lang error . i am using netbeans to run the code but editing it in j++. i am stuck here  for sometime i need help if only i can read from the jtabe i would be able to start.

here is my code

import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
public class microprocessor extends javax.swing.JFrame {
   
    /** Creates new form NewJFrame */
    public microprocessor() {
        initComponents();
    }
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jFrame1 = new javax.swing.JFrame();
        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextArea1 = new javax.swing.JTextArea();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        pause = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jTable1 = new javax.swing.JTable();
            setTitle("microprocessor");

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("continue");
        jButton1.setText("continue");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 470, -1, -1));

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 70, 120, 20));

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 200, 110, 20));

        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 70, 110, 20));

        getContentPane().add(jTextArea1, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 140, -1, -1));

        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 110, 190, 80));

        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 100, 80, 20));

        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 430, 170, 20));

        getContentPane().add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 200, 90, 20));

        pause.setText("pause");
        pause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseActionPerformed(evt);
            }
        });
        pause.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                pauseMousePressed(evt);
            }
        });

        getContentPane().add(pause, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 470, -1, -1));
            jButton2.setMnemonic('G');

        jButton2.setText("start");
        jButton2.addActionListener(new  java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                        //if (evt.getSource()==jButton2)
                        //{
                              //jTextField5.setText((String)jTable1.getModel().getValueAt(1, 2));
                        //}
               jButton2ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 470, -1, -1));

        jLabel1.setText("A");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 50, -1, -1));

        jLabel2.setText("mainmemory");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 240, -1, -1));

        jLabel3.setText("ir");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 410, 10, 10));

        jLabel4.setText("MDR");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 180, -1, -1));

        jLabel5.setText("B");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 50, -1, -1));

        jLabel6.setText("MAR");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 180, -1, -1));

        jLabel7.setText("PC");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 80, -1, -1));

        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                                                                                                 
                                                                                     
            new Object [][] {
                {new Integer(000), new Integer(01), new Integer(999)},
                {new Integer(001), new Integer(20) ,new Integer(997)},
                {new Integer(002), new Integer(02), new Integer(999)},
                        {new Integer(003), new Integer(0), new Integer(0)},
                        {new Integer(0), new Integer(0), new Integer(0)},
                        {new Integer(997), new Integer(01), new Integer(200)},
                        {new Integer(998), new Integer(00), new Integer(300)},                                                                        
                      {new Integer(997), new Integer(01), new Integer(807) }},
         //   },
                  //String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
             new String [] {
                                           "Title 1", "Title 2", "Title 3"}
            //}
        ));
        getContentPane().add(jTable1, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 260, -1, -1));

        pack();
    }//GEN-END:initComponents

    private void pauseMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pauseMousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_pauseMousePressed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));
            
            //GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField6ActionPerformed

    private void pauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pauseActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {
            //jTextField5.setText((String)jTable1.getModel().getValueAt(1, 2));
            //getContentPane().setDefaultButton(jButton2);
            
            //jText.setText((String)jTable1.getModel().getValueAt(0, 0));
            
            //GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed
   
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new microprocessor().setVisible(true);
            }
        });
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JButton pause;
    // End of variables declaration//GEN-END:variables
   
}
0
 

Author Comment

by:mnninrod
ID: 13548005
i am having a problem from reading from a jtable to the textfield area. when the start button which is jbutton2 is pressed it should copy the value 0 from the jtable to  jtextfield5 the value from jtextfield5 to jtextfield7. copy the value 01999 from the jtable to jtextfield2 and copy the value from jtextfield2 to jtextfield6 and increment the value in jtextfied5 by 1.
when using cehj comment i am getting a java lang error . i am using netbeans to run the code but editing it in j++. i am stuck here  for sometime i need help if only i can read from the jtabe i would be able to start.

here is my code

import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
public class microprocessor extends javax.swing.JFrame {
   
    /** Creates new form NewJFrame */
    public microprocessor() {
        initComponents();
    }
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jFrame1 = new javax.swing.JFrame();
        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextArea1 = new javax.swing.JTextArea();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        pause = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jTable1 = new javax.swing.JTable();
            setTitle("microprocessor");

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("continue");
        jButton1.setText("continue");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 470, -1, -1));

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 70, 120, 20));

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 200, 110, 20));

        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 70, 110, 20));

        getContentPane().add(jTextArea1, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 140, -1, -1));

        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 110, 190, 80));

        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 100, 80, 20));

        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });

        getContentPane().add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 430, 170, 20));

        getContentPane().add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 200, 90, 20));

        pause.setText("pause");
        pause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseActionPerformed(evt);
            }
        });
        pause.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                pauseMousePressed(evt);
            }
        });

        getContentPane().add(pause, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 470, -1, -1));
            jButton2.setMnemonic('G');

        jButton2.setText("start");
        jButton2.addActionListener(new  java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                        //if (evt.getSource()==jButton2)
                        //{
                              //jTextField5.setText((String)jTable1.getModel().getValueAt(1, 2));
                        //}
               jButton2ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 470, -1, -1));

        jLabel1.setText("A");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 50, -1, -1));

        jLabel2.setText("mainmemory");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 240, -1, -1));

        jLabel3.setText("ir");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 410, 10, 10));

        jLabel4.setText("MDR");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 180, -1, -1));

        jLabel5.setText("B");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 50, -1, -1));

        jLabel6.setText("MAR");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 180, -1, -1));

        jLabel7.setText("PC");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 80, -1, -1));

        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                                                                                                 
                                                                                     
            new Object [][] {
                {new Integer(000), new Integer(01), new Integer(999)},
                {new Integer(001), new Integer(20) ,new Integer(997)},
                {new Integer(002), new Integer(02), new Integer(999)},
                        {new Integer(003), new Integer(0), new Integer(0)},
                        {new Integer(0), new Integer(0), new Integer(0)},
                        {new Integer(997), new Integer(01), new Integer(200)},
                        {new Integer(998), new Integer(00), new Integer(300)},                                                                        
                      {new Integer(997), new Integer(01), new Integer(807) }},
         //   },
                  //String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
             new String [] {
                                           "Title 1", "Title 2", "Title 3"}
            //}
        ));
        getContentPane().add(jTable1, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 260, -1, -1));

        pack();
    }//GEN-END:initComponents

    private void pauseMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pauseMousePressed
        // TODO add your handling code here:
    }//GEN-LAST:event_pauseMousePressed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));
            
            //GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField6ActionPerformed

    private void pauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pauseActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {
            //jTextField5.setText((String)jTable1.getModel().getValueAt(1, 2));
            //getContentPane().setDefaultButton(jButton2);
            
            //jText.setText((String)jTable1.getModel().getValueAt(0, 0));
            
            //GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed
   
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new microprocessor().setVisible(true);
            }
        });
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JButton pause;
    // End of variables declaration//GEN-END:variables
   
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13548748
What happens when you comment out

//jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));


?
0
 

Author Comment

by:mnninrod
ID: 13549203
when i use jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));

i get this error java.lang.ClassCastException . When i freeze it nothing happens coz what i am interested in is reading from the jtable to the jtextarea.

   
0
 
LVL 92

Expert Comment

by:objects
ID: 13549567
> when i use jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));
> i get this error java.lang.ClassCastException

Use the code I posted instead.

0
 
LVL 92

Expert Comment

by:objects
ID: 13549622
jTextField5.setText(jTable1.getValueAt(0,0)+"");
0
 

Author Comment

by:mnninrod
ID: 13549833
the line that object wrote is working. but i am only left with copying two adjacent cells together  the value 01999 to jtextfield7 than i think i can start.
0
 

Author Comment

by:mnninrod
ID: 13549849
the line that object wrote is working. but i am only left with copying two adjacent cells together  the value 01999 from jtablefield to jtextfield7 than i think i can start.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13549858
>>
i get this error java.lang.ClassCastException
when i use jTextField5.setText(( String )(jTable1.getModel().getValueAt(0,0)));
>>

That's because you used the code i posted from before, and i hadn't seen your model then. You have Integer, not String in your model, so the cast would be to Integer. You can in fact do

jTextField5.setText(jTable1.getModel().getValueAt(0,0).toString());

0
 
LVL 92

Expert Comment

by:objects
ID: 13549862
the code I originaslly posted can be used to copy a range of values.

or for two adjacent cells you could also use something like:

jTextField7.setText(jTable1.getValueAt(0,0)+""+jTable1.getValueAt(0,1));
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13549872
If you want to display those leading zeros in your model, then you need to use String, as if you're using Integer, they are redundant
0
 
LVL 92

Accepted Solution

by:
objects earned 1400 total points
ID: 13549901
> That's because you used the code i posted from before, and i hadn't seen your model

no need to see the model

> jTextField5.setText(jTable1.getModel().getValueAt(0,0).toString());

that code could also cause problems.


0
 

Author Comment

by:mnninrod
ID: 13550216
i will finish the code before friday and i will post it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question