java:如何从一个启动器启动两个应用程序

发布于 2024-10-24 07:54:39 字数 695 浏览 1 评论 0原文

我有 2 个类,每个类都有一个使用它们的表单的启动器:

DateTester 使用 DateTest 类并由 dateLauncher 启动 CylinderTest 使用 Cylinder 类并由 cylLauncher 启动,

每个启动器分别简单地组成

Cylinder program = new Cylinder();

。他们自己都很好地启动了。我想做的是创建一个启动器窗口(只是一个带有两个按钮的窗格),当单击按钮时将启动任一程序。我只是将所有内容移到同一个包中(尽管我认为我现在不应该这样做),现在两者都不会从各自的启动器启动。我试图用类似的东西启动它们:

public void actionPerformed(ActionEvent ev)
{
     if(ev.getSource() == btnCylinder)
     {
          Cylinder prgCylinder = new Cylinder();
     }
     else if (ev.getSource() == btnDate)
     {
          DateTester prgDate = new DateTester();
     }
     else{}
}

但它没有做任何事情。我也尝试过将它们穿线,但这也不起作用。有什么建议吗?或者这实际上比看起来要复杂得多?

I have 2 classes, and each one of them has a launcher for a form that utilizes them:

DateTester uses DateTest class and is launched by dateLauncher
CylinderTest uses Cylinder class and is launched by cylLauncher

each launcher is simply comprised of

Cylinder program = new Cylinder();

respectively. They both launched fine by themselves. What I would like to do is create a launcher window (just a pane with two buttons) that will launch either program when their buttons is clicked. I just moved everything into the same package (although im thinking that I shouldnt have done that now), and now neither will launch from their respective launcher. I was trying to launch them with something like:

public void actionPerformed(ActionEvent ev)
{
     if(ev.getSource() == btnCylinder)
     {
          Cylinder prgCylinder = new Cylinder();
     }
     else if (ev.getSource() == btnDate)
     {
          DateTester prgDate = new DateTester();
     }
     else{}
}

but it doesnt do anything. I also tried threading them, and that didnt work either. Any suggestions? Or is this actually a lot more complicated than it seems?

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

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

发布评论

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

评论(1

那片花海 2024-10-31 07:54:39

事实证明,这只是没有为按钮添加动作侦听器。保罗在评论中回答了这个问题,但我需要按照回答关闭这个问题。谢谢保罗。

turns out it was just the action listener not added for the buttons. paulo answered this in a comment, but i need to close this as answered. thanks paulo.

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