Yudra
Yudra

Reputation: 13

Multi Issue with Super and

I am having an issue with some of the code I am working on and am looking at the errors on the sidebar of Eclipse and can't seem to figure out how to fix the issue, I search the issues with the lines in question but still cant seem to find it (spending 12 hours+ trying to fix without trying to post.)

I am trying to get the main file (StartUp.java) to display a panel from another class. Its a standard character sheet idea im using.

package mainGame;
import javax.swing.*;
public class StartUp extends JFrame{

public DataSheet(){
    super("CharacterSheet");
    setSize(1024, 768);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLookAndFeel();
    CharacterSheet charSheet = new CharacterSheet();
    add(charSheet);
    setVisible(true);
}

private void setLookAndFeel(){
    try {
        UIManager.setLookAndFeel(
                "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        SwingUtilities.updateComponentTreeUI(this);
    } catch (Exception exc){
        System.err.println("Couldn't use the system look and feel: " + exc);
    }
}


public static void main(String[] args) {
    DataSheet frame = new DataSheet();
}

}

Thanks in advance

Errors included Line 5 - The serializable class StartUp does not declare a static final serialVersionUID field of type long

Line 7 - Return Type for Method missing

Line 8 - Constructor call must be the first statement in a constructor

Line 29 shows 2 errors of the same - Constructor call must be the first statement in a constructor

Purpose was to have the StartUp just display the panel from the CharacterSheet class to the Frame of the StartUp class.

Upvotes: 0

Views: 62

Answers (1)

Ezequiel
Ezequiel

Reputation: 3592

I think that your problem is that the class name is StartUp, but the constructor is DataSheet(). Its recomended, in most of cases that you define only one class per file. So StartUp clas must implement a contructor named StartUp(), and be contained in a file named StartUp.java

Best regards.

Upvotes: 1

Related Questions