Results 1 to 4 of 4

Thread: Problem with DiveLog SampleApp

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved Problem with DiveLog SampleApp

    Hi,

    Trying to teach myself Java, and going throught the sample divelog application.

    Stuck at the first part, and seems there's a problem with the provided code where you say public DiveLog() .... something about invalid method declaration; return type required

    Here is the code (and for incase you wonder, I did create the other classes (basically empty for now) correctly. I'm using JCreator (don't want to make it to easy with using NetBeans for now)

    VB Code:
    1. package divelog;
    2.  
    3. import javax.swing.awt.*;
    4. import java.awt.*;
    5. import java.awt.event.*;
    6.  
    7. public class Divelog {
    8.    
    9.     public static void main(String[] args)
    10.     {
    11.         Divelog dl = new Divelog();
    12.     }
    13.     private JFrame dlframe;
    14.     private JTabbedPane tabbedPane;
    15.    
    16.     public DiveLog(){
    17.        
    18.         //create a frame object to add the appl gui components to
    19.         dlframe = new JFrame("A Java(TM) Technology Dive Log");    
    20.         //closes from title bar and from menu
    21.         dlframe.addWindowListener(new WindowAdapter() {
    22.             public void windowClosing(WindowEvent e)
    23.             {
    24.                 system.exit(0);
    25.             }
    26.         });
    27.        
    28.         //tabbed pane with panels for JComponents      
    29.         tabbedPane = new JTabbedPane(SwingConstants.LEFT);
    30.         tabbedPane.setBackground(Color.blue);
    31.         tabbedPane.setForeground(Color.white);
    32.        
    33.         //A method that adds individual tabs to the tabbedpane object.
    34.         populateTabbedPane();
    35.        
    36.         //Calls the method that builds the menu
    37.         buildMenu();
    38.            
    39.         dlframe.getContentPane().add(tabbedPane);
    40.         dlframe.pack();
    41.         dlframe.setSize(765, 690);
    42.         dlframe.setBackground(Color.white);
    43.         dlframe.setVisible(True);
    44.            
    45.     }  //end public DiveLog
    46.        
    47.     private void populatetabbedPane()   {
    48.        
    49.         //create tabs with titles
    50.         tabbedPane.addTab("Welcome", null, new Welcome(), "Welcome to the Dive Log");
    51.         tabbedPane.addTab("Diver Data", null, new Diver(), "Click here to enter diver data");
    52.         tabbedPane.addTab("Log Dives", null, new Dives(), "Click here to enter dives");
    53.         tabbedPane.addTab("Statistics", null, new Statistics(), "Click here to calculate dive statistics");
    54.         tabbedPane.addTab("Favorite Website", null, new WebSite(), "Click here to see a web site");
    55.         tabbedPane.addTab("Resources", null, new Resources(), "Click here to see a list of resources");
    56.                
    57.     }  //end populatetabbedPane method
    58.    
    59.     private void buildMenu() {
    60.        
    61.         //instantiate JMenuBar, JMenu and JMenuItem
    62.         JMenuBar mb = new JMenuBar();
    63.         JMenu menu = new JMenu("File");
    64.         JMenu item = new JMenu("Exit");
    65.        
    66.         //closes the application from the Exit menu item
    67.         item.addActionListener(new ActionListener()
    68.         {
    69.             public void actionPerformed(ActionEvent e)
    70.             {
    71.                 System.exit(0);
    72.             }
    73.         });
    74.        
    75.         //adds the item to the menu object
    76.         menu.add(item);
    77.         //adds the menu object with item to the menubar
    78.         mb.add(menu);
    79.         //sets the menubar in the frame
    80.         dlFrame.setJMenuBar(mb);       
    81.        
    82.     }  //end buildMenu method
    83.    
    84. } //end public class DiveLog
    Last edited by StrangerInBeijing; Apr 4th, 2005 at 03:06 AM.
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Problem with DiveLog SampleApp

    Java's case sensative, so you must have the same identifier for the constructor method as the class declaration.

    For example, you had:

    public class Divelog

    and in the constructor you had:

    public DiveLog

    using an uppercase L.

    So just change the u case L to a lower case L.

  3. #3

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: Problem with DiveLog SampleApp

    Thanx mate, will do that.
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  4. #4

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved Re: Problem with DiveLog SampleApp

    Huh-uh....even the most simple application (HelloWorld) that works fine using notepad and command prompt, give that same error....
    Not gonna use this anyhow...looks like nothing more that a cool text editor (someone's gonna hate me for that I guess)

    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

Posting Permissions

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



Click Here to Expand Forum to Full Width