package JavaGUI;
import javax.swing.*;
import java.awt.*;
public class JButton {
public static String greeting() {
return "Hello everyone!";
}
public static void main(String[]args) {
JFrame win = new JFrame("Greeting");
win.setVisible(true);
win.setSize(800,400);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.getContentPane().setBackground(Color.LIGHT_GRAY);
JButton button = new JButton("Click Me");
win.add(button);
}
}
Button eklediğim satırlarda hata çıkıyor nedendir bir türlü anlayamadım:
JButton button = new JButton("Click Me");
win.add(button);
İnternette yazılan kodun aynısı yapmama rağmen hata çıkıyor nedeni nedir bunun. Hata çıktısı:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor JButton(String) is undefined
The method add(Component) in the type Container is not applicable for the arguments (JButton)
at JavaGUI.JButton.main(JButton.java:18)
Şimdiden hepinize teşekkürler.