...

View Full Version : Debug error in simple program.



STEVIE25
12-10-2010, 04:29 PM
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

abduraooft
12-10-2010, 04:39 PM
Lesson 1: Java and javascript are entirely different. Request a moderator to move your thread to the right forum.

STEVIE25
12-10-2010, 04:46 PM
Sorry I posted this as a java programming question not a javascript so not
too sure what you are saying.

If I have posted it in the wrong sectiopn - sorry

Philip M
12-10-2010, 06:00 PM
Sorry I posted this as a java programming question not a javascript so not
too sure what you are saying.

If I have posted it in the wrong sectiopn - sorry

This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

BTW, when posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum