java applet 问题显示检索到的信息
我对以下内容有点困惑。我想创建一个小程序,它有一个包含 3 个可能选择的组合框。
当用户单击第一个选择“student1”时,
会显示 Student1 的详细信息,以及从 html 传递的参数“未标记”。与student2 =“passed”和student3 =“failed”相同
1)现在我在想,为了显示学生详细信息,是否可以在组合框中创建一个动作侦听器,以便一旦选择student1,就会显示他们的详细信息在小程序中。我可以使用文本文件吗? 干杯
im a bit stuck on the following. I want to create a applet that has a combo box with 3 possible selections.
when the user clicks the first selection "student1"
the details of student1 are shown, together with a parameter being passed from the html saying "unmarked". the same for student2="passed" and student3="failed"
1)now im thinking in order to show the student details would it be possible to make a action listener on the combo box, so that once student1 is selected their details are shown in in the applet. would i be able to use a text file?
cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
链接文本不允许小程序访问文件系统(除非您签署了小程序,这是另一个级别的复杂性,当您刚开始时,您不必担心)。
我建议您首先学习 Swing 的工作原理,这比学习如何编写小程序更重要。从 Swing 教程开始。本教程有一个关于“如何制作小程序”的部分,其中展示了如何使用 jar 文件访问数据。但我首先会让您的代码作为应用程序工作,因为应用程序更容易使用和调试。
link textApplets are not allowed to access the file system (unless you sign the applet which is another level of complexity that you should not be worried about when you are just starting out).
I suggest you start by learning how Swing works first that is more important than learning how to write an applet. Start with the Swing tutorial. The tutorial has a section on "How to Make Applets" which shows how to use a jar file to access data. But I would first get you code working as an application since applications are easier to work with and debug.
1)是的,但是您必须编写用于解析文本文件以获得正确信息的方法。
2)令人困惑的问题。您的意思是您想知道事件发生时在组合框中选择了哪个项目吗?为此,您可以使用 JComboBox.getSelectedIndex() 或 JComboBox.getSelectedItem()(同一页面)。
3) JLabels 是在小程序中显示简单文本的简单方法是的。如果需要在一个空间中显示多行文本,您还可以使用 JTextArea。
1) Yes but you will have to write methods for parsing the text file for the correct information.
2) Confusing question. Do you mean you want to know which item is selected in the combo box when an event occurs? For this you can use either JComboBox.getSelectedIndex() or JComboBox.getSelectedItem() (same page).
3) JLabels are an easy way to show simple text in an applet yes. You can also use a JTextArea if multiple lines of text need to be shown in one space.