Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6854785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:40:37+00:00 2026-05-27T01:40:37+00:00

So I am trying to make a small game for a project in college.

  • 0

So I am trying to make a small game for a project in college. I have an image class that loads the images etc. I know this class works because I tested it all when I made it. But then I decided to use a form maker, in this case WindowsBuilder Pro to make a form that was better then I could code. I am now trying to call a function that in theory will load call the images class and load the image then add that image as an imageicon to a label within a jPanel. But I am getting nothing. Any help?

    private void loadres(){
    String PROGRAM_DIRECTORY = "E:/WordGame/bin/Images/";

    Functions.Resources rs = new Functions.Resources();
    rs.loadResources();
    Functions.ImageLib iL = rs.getIL();

    try {
        BGImage = new JLabel(new ImageIcon(iL.mergeImages(iL.getImageArray(0),iL.getImage(PROGRAM_DIRECTORY + "Astroid1Image.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }

    BGImage.revalidate();
    BGImage.repaint();
}

And here is the Image functions I am using:

public class ImageLib {

private ArrayList<BufferedImage> BIArray = new ArrayList<BufferedImage>();

public ImageLib(){  
}

public BufferedImage getImage(String ref){
    BufferedImage Bi = null;

    try{
        Bi = ImageIO.read(new File(ref));
    }catch (Exception e) {  
        e.printStackTrace();
    }

    return Bi;
}

public BufferedImage resizeImage(BufferedImage Bi, int nW, int nH){
    int w = Bi.getWidth();
    int h = Bi.getHeight();

    BufferedImage nBi = new BufferedImage(nW, nH, Bi.getType());
    Graphics2D g = nBi.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

    g.drawImage(Bi,0,0,nW,nH,0,0,w,h,null);
    g.dispose();

    return nBi;
}

public void addToArray(BufferedImage img){
    BIArray.add(img);
}

public BufferedImage getImageArray(int index){
    return (BufferedImage) BIArray.get(index);
}

public BufferedImage mergeImages(BufferedImage I1, BufferedImage I2) throws IOException{
    int w = Math.max(I1.getWidth(), I2.getWidth()); 
    int h = Math.max(I1.getHeight(), I2.getHeight()); 
    BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 

    Graphics g = combined.getGraphics(); 
    g.drawImage(I1, 0, 0, null); 
    g.drawImage(I2, 0, 0, null); 
    g.dispose();

    return combined;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:40:37+00:00Added an answer on May 27, 2026 at 1:40 am

    Here is my answer ^^

    ClassLoader cldr = this.getClass().getClassLoader(); 
    java.net.URL imageURL = cldr.getResource("path/to/your/images/picture.gif"); 
    ImageIcon  imgIcon = new ImageIcon(imageURL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a small game using (free)GLUT. I know that it's old
I'm trying to build a small class-like container that will make it a little
'm trying to make a small modification to django lfs project, that will allow
Im trying to make a small app in c++ that saves midifiles with this
I'm trying to make a small Flash game that has a GUI, which is
I'm trying to make an small tower defender game in Java. I have a
I'm trying to make a small calculator, as a personal project. I have a
I'm trying to make a small game that supports Python scripting. I've no problems
I am trying to make a small game like app that has some interaction,
I'm trying to make a small game using both SFML and Box2D. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.