java:如何从一个启动器启动两个应用程序
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这只是没有为按钮添加动作侦听器。保罗在评论中回答了这个问题,但我需要按照回答关闭这个问题。谢谢保罗。
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.