Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to import my own packages

Tags:

java

import

package mainClasses;
    /*
     * Frame Info and all that ****,
     * mainFrame is the actual frame itself
     * it will refer to MainC.java a lot Main class = Main Class
     */
    import java.awt.FlowLayout;
    import java.awt.Graphics;
    import JavaGame.src.resources.*; //Problem Code
    import javax.swing.JButton;
    import javax.swing.JFrame;


    public class mainFrame extends JFrame {


private static final long serialVersionUID = 1L;

public mainFrame() {
    JButton playButton = new JButton();
    JButton infoButton = new JButton();
    JButton exitButton = new JButton();
    int x = 300, y = 300;
    setSize(x, y);
    setVisible(true);
    setLayout(new FlowLayout());
    setTitle("Kingdom Raider");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    /*Buttons and Properties*/

     playButton.setBounds(x, y, 200, 100);
     playButton.setText("Play!");
    add(playButton);

     infoButton.setBounds(x, y, 200, 100);
     infoButton.setText("Information");
    add(infoButton);

     exitButton.setBounds(x, y, 200, 100);
     exitButton.setText("Exit");
    add(exitButton);
            /* Add image here */

}

public void Painting (Graphics g) {
    //Me.
}
   }

I'm creating a game and I'm having an import problem. As you can see I want to import JavaGame.src.resources, as I'm trying to import an img. Here's how my Directory stands:

enter image description here

I don't need to know the code on resourcesmanager.java its blank at the moment. So basically, this class here is in packages mainClasses, but i want to access the resources package. What gives?

like image 671
The One that asks alot Avatar asked Apr 23 '12 15:04

The One that asks alot


1 Answers

Your package name is resources, so write this:

import resources.*; // No-Problem Code

The remaining parts of the directory structure is specific to Eclipse and doesn't have anything to do with Java classpaths

like image 110
Lukas Eder Avatar answered Oct 12 '22 07:10

Lukas Eder