在java中重新绘制一个框架

发布于 2025-01-03 12:56:19 字数 569 浏览 4 评论 0原文

我已经为在线测验编写了代码。我想通过单击“下一步”按钮来更改问题,但重新绘制不起作用;只有新窗口在工作。 我什至无法隐藏 jftMainFrame,因为它仅适用于 8 个窗口。quest 是一个包含问题和选项的列表,当我单击按钮时,从访问 db.repaint() 访问它时不起作用。 我有 4 个显示标签的单选按钮。我想重新绘制单选按钮的标签,还有问题 请帮我。

    JFrame jtfMainFrame, jtfMainFrame1;

    nextButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Next question..");
            j++;
            quest = getCurrentQuestion();
            createWindow();
            validate();               
            }
        });

I have written code for an online quiz. I would like to change questions by clicking "next" button, but repaint is not working; only new window is working.
i can't even hide jftMainFrame since it works for 8 windows only.quest is a list containing questions and options ,its accessed from access db.repaint() is not working while i click the button.
i have 4 radiobuttons which displays the label.i want to repaint the label of radiobutton and also question
Please help me.

    JFrame jtfMainFrame, jtfMainFrame1;

    nextButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Next question..");
            j++;
            quest = getCurrentQuestion();
            createWindow();
            validate();               
            }
        });

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

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

发布评论

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

评论(2

一口甜 2025-01-10 12:56:20

你的问题肯定不清楚。

你想做什么。如果您只是尝试“重新绘制/刷新”面板或组件,请使用paintImmediately();

例如

jMyPanel.paintImmediately(jMyPanel.getVisibleRect());

希望有帮助

Your question is definitely not clear.

What are you trying to do. If you are simply trying to "repaint/refresh" a panel or a component use paintImmediately();

for example

jMyPanel.paintImmediately(jMyPanel.getVisibleRect());

Hope it helps

伴梦长久 2025-01-10 12:56:19
I would like to change questions by clicking "next" button,

我认为您的问题是关于使用 CardLayout,而不是创建运行时有很多顶级容器

I would like to change questions by clicking "next" button,

I think that your question is about using CardLayout, rather than create lots of Top-Level Comtainers on runtime

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