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 8834731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:05:34+00:00 2026-06-14T09:05:34+00:00

here is the code of what i am doing: import java.net.*; import java.applet.*; import

  • 0

here is the code of what i am doing:

import java.net.*;
import java.applet.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import javax.sound.sampled.AudioFileFormat;
class GraphicsProgram extends Canvas
{
public GraphicsProgram()
{ setSize(200, 200);
setBackground(Color.PINK);
}
public static AudioFileFormat ee;
public static AudioClip ss;
public class NEW extends JApplet {
public void init() {
  ss = Applet.newAudioClip(Get_Location("/pj1/anarkali.wav"));
  ss.play();}

public URL Get_Location(String filename)
{
    URL url = null;
    try{ url=this.getClass().getResource(filename);

    }
    catch(Exception e){}
    return url;
  }
  }
   public static void main(String[] argS)
    {
GraphicsProgram GP = new GraphicsProgram();
//create a new frame to which we will add a canvas
Frame aFrame = new Frame(); aFrame.setSize(800, 800);
//add the canvas
aFrame.add(GP);
aFrame.setVisible(true); }
public void paint(Graphics g)
{
Image img01 = Toolkit.getDefaultToolkit().getImage("e:\\m.gif");
g.drawImage(img01, 110, 140, this);
Image img0 = Toolkit.getDefaultToolkit().getImage("e:\\m10.jpg");
g.drawImage(img0, 100, 140, this);
Image img2 = Toolkit.getDefaultToolkit().getImage("e:\\m2.gif");
g.drawImage(img2, 200, 140, this);
NEW ss=new NEW();
ss.init();
}
    }

I am getting:
Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError: Java heap space

but still,i am able to run it,it is playing sound and displaying images.Is it possible this way?And why i am gettin heap space error?

  • 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-06-14T09:05:35+00:00Added an answer on June 14, 2026 at 9:05 am

    You are getting this Exception because on each paint event you are loading the images. You should do this only once on initialization and then reuse the images in the paint method.

    Wait… and on every paint event you are creating a new instance of NEW which is the Applet itself. So your heap gets filled by a huge amount of Applets that’s your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code I have thus far: import java.io.*; class JAVAFilter implements FilenameFilter
So here's what I see this code doing: An array is made A loop
Here is my code which is doing the conversion from hex to decimal. The
I am doing a simple communication between sockets and here is my C++ code
What am I doing wrong here? Declare @starttimestamp datetime = getdate(); RAISERROR(N'Code not valid
Here is how I'm populating my GridView control. I'm doing this from the code-behind,
I'm doing sampling from log-normal distribution in Java using Matlab code (with javabuilder java).
I created a java project and then tried to import Java source code from
I'm doing another Java project for my class. In this assignment, we have to
The script is on jsfiddle here : CODE What it does at the moment

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.