Joptionpane不使用椭圆功能

发布于 2025-01-18 19:54:30 字数 342 浏览 3 评论 0原文

我认为代码没有任何问题,但是在循环完成之前,它并没有以某种方式显示椭圆。

我的代码是:

import javax.swing.JOptionPane;

void setup() {
  size(500, 500);
  background(255);
}

void draw() {
  for (int i = 0; i<5; i++) {
    JOptionPane.showMessageDialog(null, "you win!");
    ellipse(150, 150, 150, 150);
    delay(3000);
  }
}

感谢您提前的帮助

I don't think there is any problem with code, but somehow it is not showing the ellipse before the loop is done.

my code is:

import javax.swing.JOptionPane;

void setup() {
  size(500, 500);
  background(255);
}

void draw() {
  for (int i = 0; i<5; i++) {
    JOptionPane.showMessageDialog(null, "you win!");
    ellipse(150, 150, 150, 150);
    delay(3000);
  }
}

thanks for your help in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

司马昭之心 2025-01-25 19:54:30

draw() 函数完成之前,您不会看到屏幕上的变化。您的代码循环 5 次,每次 draw() 运行时延迟 3 秒,因此您只会看到屏幕每 15 秒更新一次椭圆。 JOptionPane 不是问题。

您应该重构代码以允许 draw() 正常更新屏幕。很难建议如何用您的示例来做到这一点,因为我不确定您的代码想要做什么。

You won't see changes to the screen until the draw() function completes. Your code loops 5 times with a 3 second delay each time draw() runs, so you'll only see the screen update with the ellipse every 15 seconds. JOptionPane is not the problem.

You should restructure your code to allow draw() to update the screen normally. It's hard to suggest how to do that with your example because I'm not sure what your code is trying to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文