【发布时间】:2016-01-04 03:20:42
【问题描述】:
我正在尝试使用 Processing 创建两个窗口。在将此标记为重复之前,由于还有其他类似的问题,我有一个特定的错误,我找不到解决方案。当我尝试add(s) 时,我收到错误The method add(Component) in the type Container is not applicable for the arguments (evolution_simulator.SecondApplet)
我不确定如何解决此问题,如果有任何帮助,我们将不胜感激。代码如下:
import javax.swing.*;
PFrame f;
void setup() {
size(320, 240);
f = new PFrame();
}
void draw() {
}
public class PFrame extends JFrame {
SecondApplet s;
public PFrame() {
setBounds(100,100,400,300);
s = new SecondApplet();
add(s); // error occurs here
s.init();
show();
}
}
public class SecondApplet extends PApplet {
public void setup() {
size(400, 300);
noLoop();
}
public void draw() {
}
}
【问题讨论】:
-
对不起,这段代码来自 pre_dinosaurus 边缘
-
您遇到的错误以及该错误的解决方案与this question 完全相同。事实上,我只是将我的答案从那里复制粘贴到这里。
标签: java image swing processing