如何让小程序看起来更好?
我想创建一个小程序,当嵌入到 html 页面时不会使它看起来像一个小程序。这意味着它应该与网页配合良好,而不应该看起来像是一些单独的东西。它看起来应该像是 HTML 的一部分。我希望我的小程序看起来很漂亮。我怎样才能做到这一点?
I want to create an applet that when embedded into html page does not make it look like an applet. Meaning it should go good with webpage and should not look as if it is some separate thing. It should look as if it's a part of HTML. I want my applet to look beautiful. How can I achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会发现 Metamorphosis 演示很有趣,因为它解释了如何使 Swing 应用程序和小程序变得更好。
http://www.jgoodies.com/freeware/metamorphosis/index.html
You might find the Metamorphosis demo interesting, as it explains how to make Swing applications and applets nicer.
http://www.jgoodies.com/freeware/metamorphosis/index.html
根据您的小程序的功能,结果可能并不完美。
如果你的小程序只是绘制不依赖GUI组件的东西,那么你只需要一个Canvas并在其中绘制漂亮的东西即可。如今,人们对网页充满期待。
如果您需要 GUI 组件(即按钮、菜单、窗口等),您就会开始遇到问题。每个操作系统都有自己的 GUI。尽管 Java 有所帮助,但要获得与操作系统 GUI 匹配的小程序已经很困难了(例如,您可能必须使用 MacOS 的 QuaQua)。您可以使用 System.getProperty() 获取操作系统名称。
但更糟糕的是,每个 Web 浏览器都可以以微妙的方式更改 GUI,并且这种情况会随着浏览器、JVM 和操作系统的每个版本而变化。您无法直接从小程序获取浏览器名称。理论上,您可以使用 JavaScript 将信息发送到小程序,并基于此构建 GUI,但实际上这将是一场噩梦。
让您的小程序变得漂亮可能比让它看起来不是小程序更容易。特别是因为第一次在浏览器中加载 JVM 的人可能会在加载 JVM 时在小程序上看到漂亮的 Java 徽标(除非您使用 1x1 小程序将其加载到较早的页面中:-)
Depending on what your applet does, the result might not be perfect.
If your applet is only drawing things that do not rely on GUI components, you just need a Canvas and draw beautiful things in it. People expect anything in web pages today.
You will start having problems if you need GUI components (i.e. buttons, menus, windows, etc...). Each OS has its own GUI. Even though Java is helping, to get an applet matching the OS GUI is already difficult (for instance you could have to use QuaQua for MacOS). You can get the OS name with System.getProperty().
But to make matters worse, each web browser can change that GUI in subtle ways, and that changes with each version of the brower, the JVM and the OS. You can't get the browser name directly from the applet. In theory, you could send the info to the applet using javascript, and build your GUI based on that, but in practice that would be a nightmare.
It might be easier to make your applet beautiful than to make it look like it is not an applet. Especially since people who are loading the JVM for the first time in the browser are likely to see an nice Java logo on your applet while the JVM is loading (unless you make it load in an earlier page with a 1x1 applet :-)