1

This is the code for a little school project and i wanted to work on it on home because their were a few errors but when i ran the project at school it worked perfectly but now when i run the project on my personal computer i get these error messages. "http://prntscr.com/lrqihg" i am using netbeans.

public class Clicker {
int first =0;
int second =0;
Clicker(){

    final JFrame dame= new JFrame("home");
    final JFrame dame1 = new JFrame("away");

    final JButton button = new JButton ("");
    button.setBounds(0,0,300,120);

    button.setIcon(new ImageIcon((getClass().getResource("/images/Coins.png"))));

    final JButton button2 = new JButton ("");
    button2.setBounds(0,130,300,120);

    button2.setIcon(new ImageIcon(getClass().getResource("/images/select.png")));

    final JButton BE = new JButton ("");
    BE.setBounds(0,260,130,117);

    BE.setIcon(new ImageIcon(getClass().getResource("/images/BE.png")));

    JButton OE = new JButton ("");
    OE.setBounds(0,400,130,117);
    OE.setIcon(new ImageIcon(getClass().getResource("/images/OE.png")));

    final JButton dutton2= new JButton ("menu");
    dutton2.setBounds(1800,20,100,40);
    dutton2.setFont(new Font("Dialog", Font.BOLD+Font.ITALIC,18));

    final JButton dutton3 = new JButton ("");
    dutton3.setBounds(650,800,700,250);
    dutton3.setIcon(new ImageIcon(getClass().getResource("/images/startbutton.png")));


     final JProgressBar bar = new JProgressBar(0,3);
     bar.setBounds(0,60,100,20);


    final JLabel label = new JLabel ("Gold # "+ first);
    label.setForeground (Color.red);
    label.setBounds(305,0,200,40);

    final JLabel championcounter = new JLabel ("Champions # "+0);
    championcounter.setForeground (Color.red);
    championcounter.setBounds(300,140,100,40);

    final JLabel splashartcounter = new JLabel ("splash art# "+0);
    splashartcounter.setForeground (Color.red);
    splashartcounter.setBounds(135,260,100,40);

    final JLabel rpcounter = new JLabel ("rp # "+0);
    rpcounter.setForeground (Color.red);
    rpcounter.setBounds(135,400,100,40);

    final JLabel tip = new JLabel ("If you own 2+ champions you get x2gold");
    tip.setForeground (Color.red); 
    tip.setBounds(300,180,240,40);

    final JLabel bg = new JLabel ();
    bg.setBounds(0,0,2000,1100);

     bg.setIcon(new ImageIcon((getClass().getResource("/images/lolmap.jpg"))));


    final JLabel bge = new JLabel ();
    bge.setBounds(0,0,2000,1100);

    bge.setIcon(new ImageIcon((getClass().getResource("/images/startscreen.jpg"))));


    dame.add(button);       
    dame.add(button2);
    dame.add(dutton2);
    dame.add(OE);
    dame.add(label);        
    dame.add(championcounter);
    dame.add(BE);
    dame.add(splashartcounter);
    dame.add(rpcounter);
    dame.add(tip);
    dame.add(bg);
    dame.add(bar);

    dame1.add(dutton3);
    dame1.add(bge);

    dame.setSize(2000,1100);
    dame.setLayout(null);
    dame.setVisible(true);
    dame.setResizable(false);
    dame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    dame1.setSize(2000,1100);
    dame1.setLayout(null);
    dame1.setVisible(true);
    dame1.setResizable(false);
    dame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    button.addMouseListener(new MouseListener(){
        public void mouseClicked (MouseEvent e){}
        public void mouseEntered (MouseEvent e){}
        public void mouseExited  (MouseEvent e){}
        public void mousePressed (MouseEvent e){
        button.setIcon(new ImageIcon(getClass().getResource("/images/coins2.png")));

        }   
        public void mouseReleased(MouseEvent e){
        button.setIcon(new ImageIcon(getClass().getResource("/images/Coins.png")));

        }
});

     button2.addMouseListener(new MouseListener(){
        public void mouseClicked (MouseEvent e){}
        public void mouseEntered (MouseEvent e){}
        public void mouseExited  (MouseEvent e){}
        public void mousePressed (MouseEvent e){

        button2.setIcon(new ImageIcon(getClass().getResource("/images/bigselect.png")));
        }   
        public void mouseReleased(MouseEvent e){
        button2.setIcon(new ImageIcon(getClass().getResource("/images/select.png")));
        }
});


    button.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
         first ++;
         label.setText("Gold #"+ first);

        }
});


    button2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if (first>=20){

                if (second==2){
                    first++;

                }
                second++;
                first -=20;
                championcounter.setText("Champions #"+second);

            }
        }
});

     BE.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if (first>=100){

                if (second==2){
                    first++;

                }
                second++;
                first -=100;
                splashartcounter.setText("splashart# "+second);

            }
        }
});

     OE.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if (first>=20){
                if (second==2){
                    first++;

                }
                first -=20;
                label.setText("Gold # "+first);

            }
        }
});

     dutton2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
         dame.setVisible(false);
         dame1.setVisible(true);
        }
});

    dutton3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        dame.setVisible(true);
        dame1.setVisible(false);
        }
});

}

public static void main(String[] args) {
    new Clicker();
}

}

  • It's difficult to be 100% sure as the line which is causing the error isn't highlighted, but, the error message suggests that the image resources you're attempting to load don't exist – MadProgrammer Dec 09 '18 at 21:54
  • Yes, after viewing your comment i looked at all the images i was missing one so i added it back into the folder and i thought that would fix the problem but it didn't. The problem was that i had the folder with all the images in different java application so i moved it to the right one and it fixed my problem! thank you so much! – Danny Mendez Dec 10 '18 at 04:35

0 Answers0