you don't have any makeFrame() method either in this class, nor in any imported static classes
try to add
public void makeFrame() {
System.out.println("foo");
}
to your Spel class and see what happens
Pergunta
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Spel
{
private JFrame frame;
public Spel()
{
makeFrame();
}
}
Here's my code. Im new to Java programming, and im trying to make a simple game. But i get this error when compiling, why is that?
EDIT: Solved this, thanks. Added new code:
private void makeFrame()
{
frame = new JFrame("Spel");
Container contentPane = frame.getContentPane();
JLabel label = new JLabel("titel");
contentPane.add(label);
frame.pack();
frame.setVisible(true);
}
Solução
you don't have any makeFrame() method either in this class, nor in any imported static classes
try to add
public void makeFrame() {
System.out.println("foo");
}
to your Spel class and see what happens
Outras dicas
makeFrame();
Here you are calling a function named makeFrame
From your code from above comment. Do it like
public class Spel
{
private JFrame frame;
public Spel()
{
makeFrame();
}
public void makeFrame()
{
frame = new JFrame("Spel");
Container contentPane = frame.getContentPane();
JLabel label = new JLabel("titel");
contentPane.add(label);
frame.pack();
frame.setVisible(true);
}
}