Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Instance of not recognised - complier error

    Dear Java Experts,

    Would very much appreciate some help with this please.

    I am new to java and am trying hard to resolve the complier error I get in Textpad.

    The error is the following.


    C:\Users\STEVIE\OPTRADER\OptraderTables.java:115: cannot find symbol
    symbol : constructor CommissionDatabase(OptraderTables)
    location: class CommissionDatabase
    CommissionDatabase CommissionsTable = new CommissionDatabase(this);
    ^
    1 error

    Tool completed with exit code 1


    My Code is as follows

    /PROGRAM TO CREATE OPTRADER MENUS

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.table.AbstractTableModel;
    import java.util.Date;
    import java.util.Calendar;
    import java.io.*;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import static java.lang.Math.*;


    class OptraderTables extends JFrame implements ActionListener, ItemListener
    {
    JCheckBoxMenuItem chbox1, chbox2;
    JRadioButtonMenuItem rb,rbCommissions;

    OptraderTables(String title)
    {
    super(title);

    //CREATE FILE MENU
    JMenu DatabaseMenu=new JMenu("DATABASE",true);
    DatabaseMenu.setMnemonic(KeyEvent.VK_D);

    //COMMISSIONS OPTION
    JMenuItem CommissionsMenu=new JMenuItem("Commissions");
    CommissionsMenu.addActionListener(this);
    DatabaseMenu.add(CommissionsMenu);

    //UNDERLYING DETAILS
    JMenuItem UnderlyingMenu=new JMenuItem("Underlyings");
    UnderlyingMenu.addActionListener(this);
    DatabaseMenu.add(UnderlyingMenu);

    //SPREAD DETAILS
    JMenuItem SpreadsMenu=new JMenuItem("Spreads");
    SpreadsMenu.addActionListener(this);
    DatabaseMenu.add(SpreadsMenu);

    //ADDS THE SEPERATOR IN MENU
    DatabaseMenu.addSeparator();

    //EXIT OPTION
    JMenuItem exitmenu=new JMenuItem("Exit");
    exitmenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
    exitmenu.addActionListener(this);
    DatabaseMenu.add(exitmenu);

    //CREATE MENU ONE WITH THREE MENU ITEM
    //AND ONE SUBMENU



    //CREATE MENU ONE WITH THREE MENU ITEM
    JMenu StrategyAnalysisMenu=new JMenu("STRATEGY ANALYSIS");
    StrategyAnalysisMenu.setMnemonic(KeyEvent.VK_P);

    JMenuItem Strategy1 = new JMenuItem("Strategy 1 SA Working On"); //MENU ITEM ONE
    Strategy1.addActionListener(this);
    StrategyAnalysisMenu.add(Strategy1);


    JMenuItem Strategy2 = new JMenuItem("Strategy 2 SA Working on"); // MENU ITEM TWO
    Strategy2.addActionListener(this);
    StrategyAnalysisMenu.add(Strategy2);

    JMenuItem Strategy3 = new JMenuItem("Strategy 3 SA Working on"); // MENU ITEM TWO
    Strategy3.addActionListener(this);
    StrategyAnalysisMenu.add(Strategy3);


    //CREATE MMENU ONE WITH THREE MENU ITEM
    JMenu TheoreticalAnalysisMenu=new JMenu("THEORETICAL ANALYSIS");
    TheoreticalAnalysisMenu.setMnemonic(KeyEvent.VK_P);

    JMenuItem ImpliedVolatilityMatrix = new JMenuItem("Implied Volatilities Matrix"); //MENU ITEM ONE
    ImpliedVolatilityMatrix.addActionListener(this);
    TheoreticalAnalysisMenu.add(ImpliedVolatilityMatrix);


    JMenuItem SpreadPositionAnalysis = new JMenuItem("Spread Position Analysis SA Working on"); // MENU ITEM TWO
    SpreadPositionAnalysis.addActionListener(this);
    TheoreticalAnalysisMenu.add(SpreadPositionAnalysis);


    JMenuBar mb=new JMenuBar();

    mb.add(DatabaseMenu); //ADD DATABASE MENU
    mb.add(StrategyAnalysisMenu); //ADD THEORETICAL ANALYSIS MENU
    mb.add(TheoreticalAnalysisMenu); //ADD THEORETICAL ANALYSIS MENU


    setJMenuBar(mb); //SETS THE MENU BAR


    setSize(380,400);
    setVisible(true);


    }

    public void actionPerformed(ActionEvent ae)
    {
    String str=ae.getActionCommand();

    if(str.equals("Commissions"))
    {
    CommissionDatabase CommissionsTable = new CommissionDatabase(this) }
    else if(str.equals("Underlyings"))
    {
    StockCodeDatabase StockCodes = new StockCodeDatabase(this);
    }
    else if(str.equals("Spreads"))
    {
    SpreadSheetCodeDatabase SpreadSheetCodes = new SpreadSheetCodeDatabase(this);
    }
    else if(str.equals("Exit"))
    {
    int returnval=JOptionPane.NO_OPTION;
    returnval=JOptionPane.showConfirmDialog(this,"Exit Optrader?","Confirmtion",JOptionPane.YES_NO_OPTION);
    if(returnval==JOptionPane.YES_OPTION)
    System.exit(0);
    }


    }


    //CHECK FOR CHECK BOX SELECTION
    public void itemStateChanged(ItemEvent ie)
    {


    }


    public static void main(String args[])
    {

    OptraderTables md=new OptraderTables("OPTRADER ™ Copyright© 2010 Stephen Avraamides");

    Dimension sd=Toolkit.getDefaultToolkit().getScreenSize();

    md.setLocation(sd.width/2-400/2, sd.height/2-400/2);
    md.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }


    }//End Class OptraderTables


    class CommissionDatabase extends JPanel
    {

    Optrader parent;

    private boolean DEBUG = false;

    public CommissionDatabase()
    {
    super(new GridLayout(1,0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);

    }



    class MyTableModel extends AbstractTableModel
    {
    private String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    private Object[][] data =
    {
    {"Kathy", "Smith",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"John", "Doe",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Sue", "Black",
    "Knitting", new Integer(2), new Boolean(false)},
    {"Jane", "White",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Joe", "Brown",
    "Pool", new Integer(10), new Boolean(false)}
    };

    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];
    }

    /*
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    */
    public Class getColumnClass(int c)
    {
    return getValueAt(0, c).getClass();
    }

    /*
    * Don't need to implement this method unless your table's
    * editable.
    */
    public boolean isCellEditable(int row, int col)
    {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col < 2)
    {
    return false;
    }
    else
    {
    return true;
    }
    }

    /*
    * Don't need to implement this method unless your table's
    * data can change.
    */
    public void setValueAt(Object value, int row, int col)
    {
    if (DEBUG)
    {
    System.out.println("Setting value at " + row + "," + col
    + " to " + value
    + " (an instance of "
    + value.getClass() + ")");
    }

    data[row][col] = value;
    fireTableCellUpdated(row, col);

    if (DEBUG)
    {
    System.out.println("New value of data:");
    printDebugData();
    }
    }

    private void printDebugData()
    {
    int numRows = getRowCount();
    int numCols = getColumnCount();

    for (int i=0; i < numRows; i++)
    {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++)
    {
    System.out.print(" " + data[i][j]);
    }
    System.out.println();
    }
    System.out.println("--------------------------");

    }



    }


    private static void createAndShowGUI()
    {
    //Create and set up the window.
    JFrame frame = new JFrame("TableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    CommissionDatabase newContentPane = new CommissionDatabase();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
    }





    }


    Help


    Kind Regards
    STEVIE25

  • #2
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Hey!

    Thats an awful lot of code to be pasted like that - makes it very hard to read.

    In future please use the code tag by clicking the little # button on the forum post thing and pasting your code within the special brackets.

    The problem is that you are trying to define a CommisionDatabase and pass it your Optrader object.

    However your code for CommisionDatabase has the following constuctor:

    Code:
    public CommissionDatabase()
    {
    super(new GridLayout(1,0));
    That is the problem. If you want the code you have to compile you need to change that to :

    Code:
    public CommissionDatabase(OptraderTables opt)
    {
    super(new GridLayout(1,0));
    However I have a funny feeling that without you recognising that yourself - your program is not going to function as you expect / want!

  • #3
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts

    Thumbs up

    OMG... I spent ages typing a response but then i clicked the wrong button and lost it all...

    dammit..time to start again then..

    Ok - when pasting code please click the # button and paste code between the code brackets makes it far easier to read.

    Second the problem is you are trying to create a CommissionDatabase object passing it a OptraderTables object however your CommissionDatabase constructor looks like this :

    Code:
    public CommisionDatabase()
    If you want this to work and compile you need to change it to :

    Code:
    public CommisionDatabase(OptraderTables opt)
    However the fact you did not spot that yourself makes me think it will compile - but not do what you want it to do!

    I also STRONGLY suggest using an IDE to do your coding in. Using a texteditor is very old school, slow, easy to make mistakes and offers no help.

    Go to www.eclipse.org and download the Java IDE and you will find that if you pasted that code in - it would probably have highlighted this problem and with a click of a button done the correction I just told you to do for you!

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hallo,

    Thank you for your help it's just I know what I am looking to do using
    a scrolling box with a table I have just used the demo code as a test
    to see how it would work.

    Many thanks.

    Reagrds
    Stevie


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •