This is for my university project and I am busting my brain around why my Java GUI does not work. This is the situation: the code compiles and executes without an issue.
This code should create 300 X 300 frame center the desktop and create circle and it print my name underneath.
I got it working until the frame, but no circle
package gui;
import javax.swing.*;
import java.awt.*;
import javax.swing.JFrame;
public class GUI extends JFrame{
public void Paint (Graphics g){
super.paintComponents(g);
g.setColor(Color.yellow);
g.fillOval(50, 50, 200, 200);
g.setColor(Color.BLACK);
g.drawArc(75, 60, 150, 150, -25, -125);
g.fillOval(100, 100, 25, 25);
g.fillOval(175, 100, 25, 25);
g.setColor(Color.BLUE);
g.setFont(new Font("Serif", Font.BOLD,18));
g.drawString("My Nanme is BOB", 33, 275);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
GUI GUI = new GUI() ;
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setSize(300,300);
GUI.setTitle("BOB's GUI App");
GUI.setVisible(true);
GUI.setLocationRelativeTo(null);
I really appreciate your output. also please give me a hint why it does not work