NetBeans:JTable: illegal forward reference

  • Context: Java 
  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Reference
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 3K views
zak100
Messages
462
Reaction score
11
Hi,
I have created a table using Netbeans. Then i have used properties->model option for table to insert row and to give column names using NetBeans frame work. Now i am trying to create an instance variable of DefaultTableModel in the application class:

DefaultTableModel model = (DefaultTableModel) figTable.getModel();

But i am getting following error:
"illegal forward reference": Move initializer to constructor.

Some body please guide me.

Zulfi.
 
Physics news on Phys.org
Hi.
I checked that link. I tried according to that but still i am getting the same thing:
public class FigureInheritanceJFrame extends javax.swing.JFrame {

final DefaultTableModel model;
model = (DefaultTableModel) figTable.getModel();

My error is :

Cannot find symbol

Symbol: class model

<identifier > expected

Illegal forward referenceSome body please guide me.

Zulfi.
 
zak100 said:
Hi.
I checked that link. I tried according to that but still i am getting the same thing:
public class FigureInheritanceJFrame extends javax.swing.JFrame {

final DefaultTableModel model;
model = (DefaultTableModel) figTable.getModel();
I could be wrong, but based on your error message, you are using model before it has been initialized. See if this gets rid of your error:
Java:
final DefaultTableModel model = null;
model = (DefaultTableModel) figTable.getModel();
zak100 said:
My error is :

Cannot find symbol

Symbol: class model

<identifier > expected

Illegal forward referenceSome body please guide me.

Zulfi.
 
Hi,
Thanks for your attention. I tried this:

Java:
final DefaultTableModel model=null;
    model = (DefaultTableModel) figTable.getModel();
but still i am getting the same error.

Some body please guide me.

Zulfi.
 
JFrame is not a subclass or super class of JTable, both of which are subclasses of awt.Window and swing.JComponent respectively whereas DefaultTableModel is one of java.swing.table.AbstractTableModel.