Java NetBeans:JTable: illegal forward reference

  • Thread starter Thread starter zak100
  • Start date Start date
  • Tags Tags
    Reference
AI Thread Summary
The discussion revolves around an issue with initializing a DefaultTableModel in a Java application using NetBeans. The user encounters an "illegal forward reference" error when trying to assign the model variable before it is properly initialized. Despite attempts to resolve the issue by setting the model to null initially, the user continues to face errors related to variable initialization and symbol recognition. A key point raised is the distinction between JFrame and JTable, highlighting that JFrame is not a subclass of JTable, which may be relevant to understanding the context of the model's usage. The conversation emphasizes the importance of proper variable initialization and the relationship between different components in the Swing framework.
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.
 
Technology 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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top