Witam mam problem z program nie chce mi sie uruchomić, w Eclipse mimo iż w książce Java Podstawy wydanie X jest napisane wyraźnie ze jest to kompletny program do uruchomienia . Wyswietla mi sie błąd :
"Error: Main method not found in class plaf.PlafFrame, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application"
Teoretycznie jestem w stanie zmienić kod, zastanwia mnie jedno czy kod da sie uruchomić bez metody main(), jeżeli tak to chciałbym wiedzieć jak to zrobić na przykladzie podanego kodu z str534.Pozdrawiam
package plaf;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PlafFrame extends JFrame
{
private JPanel buttonpanel;
public PlafFrame()
{
setSize(300,200);
JButton button_red = new JButton("RED");
JButton button_yellow = new JButton("YELLOW");
JButton button_blue = new JButton("BLUE");
buttonpanel = new JPanel();
buttonpanel.add(button_blue);
buttonpanel.add(button_yellow);
buttonpanel.add(button_red);
add(buttonpanel);
ColorButton red = new ColorButton(Color.RED);
ColorButton yellow = new ColorButton(Color.YELLOW);
ColorButton blue = new ColorButton(Color.BLUE);
button_blue.addActionListener(blue);
button_yellow.addActionListener(yellow);
button_red.addActionListener(red);
}
private class ColorButton implements ActionListener
{
private Color backgroundcolor;
public ColorButton(Color c)
{
backgroundcolor=c;
}
public void actionPerformed(ActionEvent event)
{
buttonpanel.setBackground(backgroundcolor);
}
}
}