问题标签 [acm-java-libraries]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1216 浏览

java - 为什么我的 java“GRect”类不能在 eclipse 上工作?

当我尝试在 Eclipse 上测试运行以下代码时,Java 小程序出现了,并且只显示了一个正方形。但它没有显示 (rect2) 矩形

或(GLabel)“你好世界”。

整个代码:

0 投票
1 回答
2932 浏览

java - 如何使用 ACM 库 (ConsoleProgram) 编写我的 Java 程序?

我想问一个关于我的程序的小问题。

这是我的代码示例:

如何将此代码示例转换为 ConsoleProgram(位于 ACM 库中)?我必须更改或添加哪些部分?

我开始:

但我不知道下一步该做什么。

0 投票
3 回答
6845 浏览

java - 无法在 JTextfield 中键入或删除文本

我正在使用 Java 的艺术和科学(使用 Java SE 6u45)学习 Java。尝试通过在 JTextField 中输入新的字体类型来更改文本的字体。但问题是我无法在 JTextField 中输入任何文本。这个问题对于我使用过的其他摆动组件(如 JButton、JCheckBox)很常见。但是在后面的组件中,我可以看到选择的效果,即使视觉选择保持不变,这意味着即使单击后复选框仍保持选中状态,但代码显示未选中框的结果。

但是在 JTextField 的情况下,甚至没有显示效果。我也不能删除我放在 JTextField 中的测试文本。尝试使用isEditable(),grabFocus()isFocusable(). 会不会是 Java 错误?

0 投票
1 回答
1117 浏览

java - 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 :

The problem is the equality.

The program should check the variables is true or false.

For instance :

this program does like bellow:

give a number for p : 1(user will give a number one (true) or zero(false))
give a number for q : 0
give a number for s : 1
give a number for t : 0
give a number for k : 0
(if the variable use more than one, program will ask once)

If we look at these variables, we can see that (1 or 0 or 1 or 0 or 0) and (1 or 0) It will return true but I can't do this. I can't understand how to do it.

Best wishes.

0 投票
1 回答
2133 浏览

java - Problems with Brick Collision Detection in BreakOut game

I've done my first BreakOut Game while completing an assignment for Stanford University CS Online Course for java.

However I noticed during play testing that when the ball sometimes hits a brick while travelling diagonally it ends up hitting several bricks in a row in a unnatural way.

I'm guessing I have to improve a bit my collision detection code and I tried several things already to no avail.

I'm using the ACM library for this program. An imaginary Rectangle surrounds my ball and I use the 4 corners of that rectangle to detect collision.

During the game, since I added several addons (items that drop and give you bonus) there are lot of velocity changes in the game - the vx variable change a lot.

I think this is related to my problem, because I noticed that it's when the ball travels at more speed than more of this several bricks destroyed in a row problem.

I´ll add the relevant code here. You can however check out all of the code here: https://gist.github.com/frodosda/5604272

Thanks in advance for your help!

0 投票
1 回答
478 浏览

java - Java如何使用来自acm的clear()?

我创建了一个对象(GPolygon),将它添加到画布,我旋转它,然后我想重置旋转,回到开始的地方。我查看 acm 页面,有一个名为 clear() 的方法,但我无法访问它,可能是因为受到保护。来自http://www-cs-faculty.stanford.edu/~eroberts//jtf/javadoc/complete/acm/graphics/GPolygon.html#clear()的文本

我如何在这个对象上使用 clear() 方法?这是我的多边形代码: Java

谢谢 !

0 投票
1 回答
138 浏览

java - ACM Interactors Freeze

I'm trying to make a very simple program with Swing and ACM interactors. It is taken directly from a class handout, but does not function on my computer. When I run it, it functions fine for about half a second, then briefly flashes, reloads, and then all button and text-field functionality is lost. Here's the code:

If it helps, I'm using Java SE 1.6 with Eclipse Helios Service Release 2 on a mid-2010 Mac Pro running Mac OSX 10.8.4

0 投票
0 回答
853 浏览

java - 无法移动图像

我正在尝试将图像从右向左移动。我要移动的图像是另一个类中的 drawTrain 方法。我想我必须将 drawTrain 方法与 move() 方法一起使用。但是,我不知道该怎么做。或者我完全错了,必须有另一种解决方案。到目前为止,我尝试使用类似的东西

好吧..失败了..我试图搜索和谷歌以及一切,但我只是坐着花几个小时。如果我想做的是正确的,我怎么能在另一个类中移动一个方法?如果没有,我做错了什么,我该如何解决?

我的司机班

培训班..我正在尝试在 Driver 类中调用此类中的方法。

0 投票
2 回答
874 浏览

java - 非常基本的 GObject/GOval For-Loop

我目前正在学习我的 AP Java 编码课程,但遇到了一个有趣的问题。

我正在尝试使用 GObjects/GOval 在图形窗口中创建 100 个具有各种半径和随机颜色的随机圆。我试图找出问题所在,并且我确信 for-loop 和 GOval (circle) 创建之间的通信有问题。我也曾尝试从头开始多次重做此代码,但我一直遇到同样的问题。具体来说,我的问题是我的图形窗口只显示一个随机圆圈而不是 100 个。请帮忙。我的代码如下:

请注意,我选择了变量 c 来随机指定颜色。没有押韵或理由,我只需要使用一个随机值。

0 投票
0 回答
838 浏览

java - 使用Java的ACM库画房子

好吧,我是 Java 新手,这些天我用 acm.library 练习。我必须创建一个有 2 个窗户、一个门和一个屋顶的房子。但是,无论形状的宽度和高度如何,我都希望它们以它们的位置为中心。

我刚刚将房子的墙壁居中,现在我需要一些关于如何将门放置在房子的中心以及如何将 2 个窗户放置在门的左右两侧的帮助。

编辑:用门和左窗完成!!!

这是我的代码: