Results 1 to 4 of 4
- 12-17-2010, 10:31 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
java:92: cannot find symbol error
I am sooo new to Java and am under the gun to learn it quickly and mostly on my own - probably not a new story, but it's new for me. :D
Found code on open source forum and modified as a learning tool for me and to record my media collection. When I compile the main() and when I compile the AddEntry() and UpdateEntry() I get the same compile error, but for the life of me I don't see syntax errors:
HERE'S MY ERROR:
************************************************** ****
./MediaCollectionMain.java:92: cannot find symbol
symbol : method setValueAT(java.lang.String,int,int)
location: class javax.swing.JTable
jTable.setValueAT(media.getType(), rowCnt, 0);
^
1 error********************************************* ****
Please advise... source follows.
Thanks,
noviceNewbie :eek:
My MediaCollectionMain() is:
Java Code:public class MediaCollectionMain extends javax.swing.JPanel { private static javax.swing.JTable jTable; private javax.swing.JScrollPane jScrollPane; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private static int rowCnt = 0; private static int selectedRow; public MediaCollectionMain() { jTable = new javax.swing.JTable(new AbstractTable()); //Table Column size javax.swing.table.TableColumn column = null; for(int i = 0; i < 6; i++) { column = jTable.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(10); } else if(i == 1) { column.setPreferredWidth(50); } else if(i == 3) { column.setPreferredWidth(6); } else { column.setPreferredWidth(35); } } jScrollPane = new javax.swing.JScrollPane(jTable); jPanel1 = new javax.swing.JPanel(new java.awt.BorderLayout()); jPanel1.add(jScrollPane, java.awt.BorderLayout.CENTER); jButton1 = new javax.swing.JButton("Add Entry"); jButton2 = new javax.swing.JButton("Update"); jButton3 = new javax.swing.JButton("Delete"); jButton4 = new javax.swing.JButton("Close"); jPanel2 = new javax.swing.JPanel(new java.awt.FlowLayout()); jPanel2.add(jButton1); jPanel2.add(jButton2); jPanel2.add(jButton3); jPanel2.add(jButton4); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { new AddEntry().setVisible(true); } }); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { new UpdateEntry(jTable.getValueAt(getSelectedRow(), 0).toString(), jTable.getValueAt(getSelectedRow(), 1).toString(), jTable.getValueAt(getSelectedRow(), 2).toString(), jTable.getValueAt(getSelectedRow(), 3).toString(), jTable.getValueAt(getSelectedRow(), 4).toString(), jTable.getValueAt(getSelectedRow(), 5).toString()).setVisible(true); } }); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { removeEntry(); } }); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { setVisible(true); System.exit(0); } }); jPanel1.add(jPanel2, java.awt.BorderLayout.SOUTH); jPanel1.setPreferredSize(new java.awt.Dimension(750, 300)); add(jPanel1); } public static void addEntry(Media media) { jTable.setValueAT(media.getType(), rowCnt, 0); jTable.setValueAt(media.getTitle(), rowCnt, 1); jTable.setValueAt(media.getGenre(), rowCnt, 2); jTable.setValueAt(media.getYear(), rowCnt, 3); jTable.setValueAt(media.getAuthor(), rowCnt, 4); jTable.setValueAt(media.getStudio(), rowCnt, 5); rowCnt++; } public static void editEntry(Media media) { jTable.setValueAt(media.getType(), getSelectedRow(), 0); jTable.setValueAt(media.getTitle(), getSelectedRow(), 1); jTable.setValueAt(media.getGenre(), getSelectedRow(), 2); jTable.setValueAt(media.getYear(), getSelectedRow(), 3); jTable.setValueAt(media.getAuthor(), getSelectedRow(), 4); jTable.setValueAt(media.getStudio(), getSelectedRow(), 5); } public void removeEntry() { for(int i = getSelectedRow(); i < rowCnt; i++) { jTable.setValueAt(jTable.getValueAt(i + 1, 0), i, 0); jTable.setValueAt(jTable.getValueAt(i + 1, 1), i, 1); jTable.setValueAt(jTable.getValueAt(i + 1, 2), i, 2); jTable.setValueAt(jTable.getValueAt(i + 1, 3), i, 3); jTable.setValueAt(jTable.getValueAt(i + 1, 4), i, 4); jTable.setValueAt(jTable.getValueAt(i + 1, 5), i, 5); } rowCnt--; } public static int getSelectedRow() { jTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); javax.swing.ListSelectionModel rowSel = jTable.getSelectionModel(); rowSel.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; javax.swing.ListSelectionModel sel = (javax.swing.ListSelectionModel)e.getSource(); if (!sel.isSelectionEmpty()) { selectedRow = sel.getMinSelectionIndex(); } } }); return selectedRow; } class AbstractTable extends javax.swing.table.AbstractTableModel { private String[] columnNames = { "Type", "Title", "Genre", "Year", "Author", "Studio" }; private Object[][] data = new Object[100][5]; public int getColumnCount() { return columnNames.length; } public int getRowCount() { return data.length; } public String getColumnName(int col) { return columnNames[col]; } public Object getValueAt(int row, int col) { return data[row][col]; } public void setValueAt(Object value, int row, int col) { data[row][col] = value; fireTableCellUpdated(row, col); } } public static void main(String args[]) { javax.swing.JFrame.setDefaultLookAndFeelDecorated(true); javax.swing.JFrame jFrame = new javax.swing.JFrame("Media Collection"); jFrame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); jFrame.setResizable(false); jFrame.getContentPane().add(new MediaCollectionMain()); jFrame.pack(); jFrame.setVisible(true); } }Last edited by noviceNewbie; 12-17-2010 at 11:12 PM. Reason: insert code tags
-
Hello and welcome to Java-Forums.org.
When posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
You'll also want to post your error messages and somehow indicate to us which line is causing the error.Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
Luck!
- 12-18-2010, 01:40 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
I found my own error...
had to step away from it for awhile and come back - it was starring me in the face! setValueAT instead of setValueAt... doh! :p
-
Similar Threads
-
Cannot find symbol error
By rajivjoshi in forum New To JavaReplies: 3Last Post: 05-31-2010, 10:13 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
'Cannot find symbol' error
By minihazard10 in forum New To JavaReplies: 6Last Post: 10-10-2008, 04:05 AM -
[SOLVED] Java Error: Cannot find Symbol...
By bobleny in forum New To JavaReplies: 8Last Post: 04-15-2008, 06:35 AM -
Error: cannot find symbol
By silvia in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:39 AM


LinkBack URL
About LinkBacks

Bookmarks