Questions tagged [acm-java-libraries]

The ACM Java Libraries were produced by the ACM's Java Task Force with the aim of simplifying the teaching of Java to first-year undergraduate students.

The ACM Java Task Force Libraries and API were produced by the Association of Computing Machinery's Java Task Force with the aim of simplifying the teaching of Java to first-year undergraduate students.

As observed here and here, it may be necessary to compile under Java 1.5 to avoid regressions seen with later versions of Java.

113 questions
0
votes
1 answer

Why doesn't my java "GRect" class work on eclipse?

When I try to test run the below code on Eclipse, the Java applet shows up, and only shows me a square. But it doesn't show the (rect2) rectangle GRect Rect2 = new GRect (300, 75, 200, 100) ; Rect2.setFilled (true) ; Rect2.setColor (Color.RED) ;…
Shazza
  • 41
  • 1
  • 4
0
votes
3 answers

Basic Java Graphics and coordinates not working properly

I've done quite a bit with the acm graphics library in the past and I've just begun working on the breakout problem that Stanford assigns. One of the issues which I've had several times in the past with graphics is the coordinates do not accurately…
user705185
0
votes
1 answer

How do you remove one box to continue a 'for' loop in java?

I'm new to java and I am trying to write a code that generates 10 random boxes then removes one box and adds another. Thus the total remains 10 boxes, but the loop keeps going. I have figured out how to create the 10 random boxes, but I am unsure…
user1805052
  • 25
  • 1
  • 3
0
votes
3 answers

What does a thread 3 NullPointerException mean in my code?

I keep getting this error when I compile and run my Java program using the ACM library Exception in thread "Thread-3" java.lang.NullPointerException at SpaceTravel.getBlackHoleDistance(SpaceTravel.java:148) at…
ahtmatrix
  • 539
  • 1
  • 7
  • 19
0
votes
3 answers

When creating objects through iteration, how do I get a specfic object?

I got an instance variable of type GRect private GRect brick; that I create several of, through iteration private void makeBrickLineX(int x, int y, Color color) { for (int i = 0; i < NBRICKS_PER_ROW; i++, x +=…
Tom Lilletveit
  • 1,872
  • 3
  • 31
  • 57
0
votes
2 answers

How can I combine multiple ACM graphics objects in Java into one object?

I have finished writing a Hangman game, but I want to move the hangman out of the canvas when the game is over. I create that hangman with any partition of his body. When I move the object it can move only one object at a time. How can I bunch them…
DrNutsu
  • 475
  • 2
  • 10
  • 21
0
votes
1 answer

How to fix Animation (Java) Need help =]

The program detects left and right arrow keys. If any of those keys are pressed, my Knight object which is an instance of GImage class goes through an array of strings(those strings are directory path to my animation of the Knight object. The…
Nicholas
  • 679
  • 2
  • 11
  • 29
0
votes
1 answer

What wrong with my code , I can't use KeyPressed method?

public void run() { setSize(700,700); setGame(); } public GObject drawPlayer() { GOval player = new GOval(getWidth()/2,getHeight()/2,10,10); player.setFilled(true); player.setFillColor(Color.red); return player; } public void…
DrNutsu
  • 475
  • 2
  • 10
  • 21
0
votes
1 answer

Java / ACM: Why doesn't my object move?

I'm currently going through Eric Robert's Art and Science of Java, which uses the ACM Java libraries. One of the exercises has the student build a clone of Breakout. I'm having issues with the animation of objects, so please have a look at this code…
0
votes
1 answer

Converting ACM graphics window to image file

I'm new to this website and relatively new to Java. I've created a Java application that uses the ACM graphics package and extends a GraphicsProgram. I want to now be able to convert the contents of my graphical output window into an image file such…
somedude
  • 21
  • 1
0
votes
1 answer

Embed .jar file in html that require .txt file (java)

I'm using the acm libraries for my Java program, and I want to embed my program into my website via HTML. I have other .jar files embedded just fine in my website, by using the
etufte252
  • 3
  • 1
-1
votes
2 answers

Java acm ComplexNumber Class cannot be instantiated?

Can someone help me find out why my code doesn't work? I litterally have no clue why it won't work. It says java.lang.InstantiationException and every post i search in the internet tells me that abstract classes cannot be instantiated, but this is…
-1
votes
1 answer

When I run this code it is not allowing me to input to my scanner. Am I using the Scanner properly?

When I run the code I am not able to input to the scanner and continue through the code the way I want to. Can someone help me with some advice? I have imported the java.util.Scanner succesfully. BTW, I do call the method in the original program, I…
DSATH
  • 23
  • 5
-1
votes
1 answer

How do I use a variable that is declared inside of a for loop outside the loop?

I'm creating ATARI BREAKOUT, using the acm.graphics library and I'm trying to access a "brick" outside of my for loop to delete it. I can't figure out any other way to create the bricks without the for loop. Help? GRect brick = new GRect(brickwidth,…
-1
votes
1 answer

Using import acm.program for java?

Is there any standard coding syntax in java? I was using System.acm.println while one of the stanford videos imports acm.program and use println for the same output.