Wednesday, May 14, 2014

Help please!!!!!
































































Im having trouble. Whenever I try to run this code, it closes right away and I can't figure out why and i want to figure this out.































































Heres the code:
































































import java.util.Random;
































































import java.util.Scanner;































































import java.awt.*;
































































import javax.swing.*;































































import javax.swing.JFrame;































































import javax.swing.JPanel;































































class magic8ball extends JPanel {
































































public static void main(String[] args)































































{
































































int number;































































Random myRandom = new Random();































































Scanner myScanner = new Scanner(System.in);































































number = myRandom.nextInt(1) + 1;}































































public void paintComponent1(Graphics g) {
































































Random myRandom = new Random();































































int number = myRandom.nextInt(1) + 1;;































































switch (number)































































{
































































case 1:































































g.setColor(Color. MAGENTA);































































g.fillRect(0,0,3000,3000);































































g.setColor(Color. black);































































g.fillOval(300,300,100,100);
































































break;































































}































































}
































































public magic8ball () {
































































}































































public void paintComponent(Graphics g) {































































super.paintComponent(g);































































{
































































}































































}
































































{































































magic8ball t = new magic8ball();































































JFrame jf = new JFrame();































































jf.setTitle("box");































































jf.setSize(600,400);































































jf.setVisible(true);































































jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);































































jf.add(t);
































































}































































}































































































































No comments:

Post a Comment