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
1
vote
2 answers

Very basic GObject/GOval For-Loop

I am currently taking my an AP Java Coding class and I am running into an intersting problem. I am trying to create 100 random circles with various radii, and random colors in a graphics window using GObjects/GOval. I have tried to isolate the…
TheZac2613
  • 21
  • 5
1
vote
0 answers

Cannot move an image

I am trying to move an image from right to left. The image I am trying to move is drawTrain method in another class. I think I have to use drawTrain method with move() method. However, I do not know how to do that.. Or I'm totally wrong and there…
1
vote
1 answer

Java how to use clear() from acm?

I create an object (GPolygon), add it to canvas, i rotate it and then i want to reset the rotation, to come back where started. I look at acm page and there is a method called clear() but i can't acces it, probaly because is protected. Text from…
1
vote
1 answer

How can i do cnf operator in java?

I'm trying to do CNF operator in Java and I have an error with equality. Firstly, I did most of the software but I didn't do totally. My codes are here : import acm.program.*; public class split extends ConsoleProgram{ public void run() { …
CWOmer
  • 101
  • 1
  • 2
  • 11
1
vote
3 answers

Unable to type or delete text in JTextfield

I'm learning Java using Art and Science of Java (using Java SE 6u45). Trying to Change the font of text by entering the new font type in a JTextField. But the problem is that I can't enter any text in JTextField. The problem is common to other swing…
1
vote
4 answers

Need help running program using ACM Java Libraries in Eclipse

I just started taking the Stanford CS106a course on iTunes, but I'm running in to problems with Eclipse. Here's my code: /* * File: Add2Integers.java * ----------------------- * A simple ConsoleProgram to add two integers * and display their…
Kris
  • 11
  • 1
1
vote
2 answers

Getting NullPointerException when making GImage

So here is a part of my code thats throwing NullPointerException: public class PuzzleGame extends GraphicsProgram implements KeyListener{ private ArrayList list = new ArrayList (); private PuzzleImage…
user2116860
1
vote
1 answer

Java acm, GRect method, Inheritance add method doesnt show

I am reading about inheritance. I tried to do the example but something is amiss. I wrote every bit of code but a certain method which was suppose to be inherited doesnt show. the method is add(GObject arg) Here is the code for the class: package…
1
vote
1 answer

Java: MouseListeners and returning objects

So I got this simple MouseListener set up. and I want it to get me which object I am pointing at. But it don´t seem´t work on GObjects, which are part of the acm library and included GRects, GLabels etc... it only returns to me the GCanvas itself…
Tom Lilletveit
  • 1,872
  • 3
  • 31
  • 57
1
vote
1 answer

Instance variable initialized in constructor of class becomes null in overridden method

Here I have a simple class that extends a class in the ACM graphics library called GRect. Grect is a basic rectangle that can be drawn to a GCanvas (Also part of ACM). What I want to achieve is a new object that is a rectangle, but has an attached…
Mimetic
  • 381
  • 2
  • 7
1
vote
2 answers

GImage can't find my image

I was trying the acm library and when I tried to use the GImage it can't find my image. I tried putting it everywhere and still it can't find it. Where does GImage look for an image(please be specific) thank you
ptc referal
  • 11
  • 1
  • 2
1
vote
1 answer

Creating a moving object when user presses a key (Java)

The idea of my program is to create a picture and have that picture move up in a graphical window, which is exactly what the rollBall() method does. The method works when I put the rollBall() method in the run() method. But the issue lies it cannot…
Nicholas
  • 679
  • 2
  • 11
  • 29
0
votes
2 answers

JButton does not function visually

I'm using a few interactors in the following class. All of them function perfectly i.e. they do what I want. However, they don't work visually. For example, when I press the JButton, which is intended to clear the screen it does so, but the JButton…
rbharvs
  • 45
  • 6
0
votes
1 answer

How do you simply obtain an array of pixel data from an image by java?

I need to work code to analyze the image to pixels in the form of an array. Please help me
Fofo
  • 1
  • 2
0
votes
1 answer

Moving a GOval object in circular motion using movePolar method in java

I am currently creating a small project, using ACM graphics library, where you will have to move the ball (or an object) of GOval using method movePolar to move in circular motion. So far I know that there are two arguments in movePolar() where the…