开发者

call to super first line

I am a newbee so advise and help is always greatly appreciated.

Cannot seem to get my container contentPane to display the title.

My code:

class CreateStockCodeDetails extends JFrame implements ActionListener 
{ 

     OptraderSA parent; 


     OptraderGlobalParameters GV = new OptraderGlobalParameters(); 
     private boolean DEBUG = true; //Set DEBUG = true for Debugging 

JButton SAVE_BUTTON     = new JButton("SAVE"); 
JButton CANCEL_BUTTON   = new JButton("CANCEL"); 

Font MyFont         = new Font("Helvetica",Font.BOLD,24); 

JLabel PriceBidLabel   开发者_如何学Go        = new JLabel("  Bid Price",JLabel.LEFT); 
JLabel PriceAskLabel           = new JLabel("  Ask Price",JLabel.LEFT); 
JLabel PriceMidLabel           = new JLabel("  Mid Price",JLabel.LEFT); 
JLabel DividendLabel           = new JLabel("  Dividend",JLabel.LEFT); 

JTextField PriceBid    = new JTextField(5); 
JTextField PriceAsk    = new JTextField(5); 
JTextField PriceMid    = new JTextField(5); 
JTextField Dividend           = new JTextField(5); 

JTextField NewUnderlyingCode  = new JTextField(10); 

String NewCode; 

 public void CreateStockDetails(String StockCode) 
 { 
       **super("Hallo All");** 

       Container contentPane = getContentPane(); 
       setSize(400,500); 
       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 

       //Centre Screen To Right Of Main 
  Dimension sd=Toolkit.getDefaultToolkit().getScreenSize(); 
  super.setLocation(sd.width/2-100/2, sd.height/2-300/2); 

Thanks

Kind Regards Stephen


First, note that you can only call super("Hallo All") in your constructor.

As I see it you have two problems:

  1. A constructor has no return type. Thus remove void
  2. The constructor must have the same name as the class.

That is, change from

 public void CreateStockDetails(String StockCode) 
 { 
       **super("Hallo All");** 

to this

 public CreateStockCodeDetails(String StockCode) 
 { 
       super("Hallo All");

Also, as a side-note: According to Java conventions, you should use lower case initial letters for variable identifiers, that is, write stockCode instead of StockCode and you should not have a new-line before opening braces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜