获取切换卡的按钮

发布于 2024-12-25 13:47:51 字数 258 浏览 2 评论 0原文

我有一个登录 GUI,当我单击按钮时,它会从用户名和密码中获取文本,如果正确,它会移至新面板。我有一个名为 optionPanel 的面板,我希望按钮专门转到它。所有面板都设置为卡片,因此我可以在它们之间顺利切换。我知道如何使按钮移动到序列中的下一个面板/卡,但我不知道如何使其转到名为 optionPanel 的面板/卡。

编辑: 我不知道我说得是否清楚,但在我看来,这是完全有道理的。请告诉我如何才能更清楚,以便我得到答案。 谢谢

I have a log in GUI that when i click a button, it gets text from the username and password, and if it is correct, it moves on to a new panel. i have the panel called optionPanel and i want the button to go to it specifically. all of the panels are set up as cards, so i can switch between them smoothly. I know how to make the button move to the next panel/card in the sequence, but i don't know how to make it go to the panel/card called optionPanel.

EDIT:
I dont know if im being very clear, but in my head, this makes perfect sense. please tell me how i can be more clear so i can get an answer.
THANKS

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

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

发布评论

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

评论(2

扎心 2025-01-01 13:47:51

我想你想要的是:

// Create the panels
JPanel loginPanel = new JPanel();
JPanel someOtherPanel1 = new JPanel();
JPanel someOtherPanel2 = new JPanel();
JPanel optionPanel = new JPanel();
JPanel someOtherPanel3 = new JPanel();

// Add them to a card layout
JPanel cards = new JPanel(new CardLayout());
cards.add(loginPanel, "loginPanel");
cards.add(someOtherPanel1, "someOtherPanel1");
cards.add(someOtherPanel2, "someOtherPanel2");
cards.add(optionPanel, "optionPanel");
cards.add(someOtherPanel3, "someOtherPanel3");

...

// Switch to the optionPanel
cards.getLayout().show(cards, "optionPanel");

I think what you want is:

// Create the panels
JPanel loginPanel = new JPanel();
JPanel someOtherPanel1 = new JPanel();
JPanel someOtherPanel2 = new JPanel();
JPanel optionPanel = new JPanel();
JPanel someOtherPanel3 = new JPanel();

// Add them to a card layout
JPanel cards = new JPanel(new CardLayout());
cards.add(loginPanel, "loginPanel");
cards.add(someOtherPanel1, "someOtherPanel1");
cards.add(someOtherPanel2, "someOtherPanel2");
cards.add(optionPanel, "optionPanel");
cards.add(someOtherPanel3, "someOtherPanel3");

...

// Switch to the optionPanel
cards.getLayout().show(cards, "optionPanel");
挽清梦 2025-01-01 13:47:51

难道你不需要

cardLayout.show(cards, "optionPanel");

或者我错过了一些完全不明显的东西吗?

don't you just need

cardLayout.show(cards, "optionPanel");

or am i missing something completely non-obvious?

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