如何进行小程序调用并运行另一个小程序 [英] How can I make an applet call and run another applet

查看:85
本文介绍了如何进行小程序调用并运行另一个小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个小程序游戏,但是我想在开头添加一个开始"关闭"菜单.我想知道是否可以将菜单作为一个单独的小程序,当按下开始"时,它会调用并运行另一个小程序?

I have made a game as an applet however I want to add a "start" "close" menu at the beginning. I was wondering if its possible to make the menu as a separate applet and when "start" is pressed, it will call and run the other applet?

推荐答案

首先,不要这样做,这实际上不是您的代码应该如何工作的.您的开始/关闭菜单应该在同一个小程序上下文/容器中.

First of all, don't, this isn't really how you code should work. Your start/close menus should be within the same applet context/container.

你可以使用类似 CardLayout 的东西来摇摆不同面板之间的视图切换.

You could use something like CardLayout to vacillate the switching of the views between different panels.

这允许您将 Applet 简单地用作其他视图的容器,并根据您自己的规则和要求切换这些视图.查看如何使用 CardLayout 了解更多详情

This allows you to use the Applet simply as a container for other views and switch those views based on your own rules and requirements. Take a look at How to Use CardLayout for more details

但是,从您看来,您已经将所有逻辑直接编码到小程序本身中,正如您所发现的那样,这是一个坏主意.

But from what you seem to be saying, you've coded all you logic directly into the applet itself, which is a bad idea, as you've discovered.

其次,鉴于现在大多数浏览器都在积极阻止小程序,继续使用它们并没有多大意义(并且管理中增加的复杂性使它们没有吸引力)

Secondly, given the fact that most browsers are now days actively blocking applets, it doesn't really make a lot of sense to continue using them (and the added complexity in there management make them unappealing)

更好的解决方案可能是首先使用 JPanel 作为您的主要容器,将 CardLayout 应用到它并将每个视图作为单独的组件.这现在为您提供了额外的灵活性,可以决定如何显示程序、小程序、框架或其他容器

A better solution might to start by using a JPanel as you primary container, apply a CardLayout to it and having each view as separate components. This now provides you the added flexibility of been able to decide how to display the program, applet, frame or other container

这篇关于如何进行小程序调用并运行另一个小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆