开发者

java applet questions displaying retrieved information

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 studen开发者_如何转开发t1 is selected their details are shown in in the applet. would i be able to use a text file? cheers


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) 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜