java - Displaying Applets With HTML Document -
I created a program for my Java class and part of the assignment is that I need to create an HTML document Applet I have not learned a lot about HTML, so I do not know how to create a document. Can someone help me? Here's my code:
import java.awt. *; Import java.awt.event. *; Public class color {button button 1; Button Button 2; Button button3; Textfield textbox; Label label 1; Public static zero main (string algos []) {colors c = new colors (); } Public color () {frame F = new frame ("color"); Button Button 1 = New Button ("Blue"); Button1.setBounds (0,205,100,75); Button Button 2 = New Button ("Red"); Button2.setBounds (100205,100,75); Button Button 3 = New Button ("Yellow"); Button3.setBounds (200,205,100,75); F.add (Button1); F.add (Button2); F.add (Button3); Textbox = new textfield ("", 0); Textbox.setBounds (8010512525); Textbox.setText ("Which Color?"); F.add (text box); Label1 = new label ("click on a button to choose a color"); F.add (label1); F.addWindowListener (New Window Adapter) {Public Zero Window Closed (Window Event We) {System.exit (0);}}); F.setSize (300300); F.setVisible (true); Button1.addActionListener (new executable () {executed public zero verb} {textbox.setText ("blue"); textbox.setForeground (color.blue);}}); Button2.addActionListener (new executable () {public zero action action (ActionEvent evt) {textbox.setText ("Red"); textbox.setForeground (Color.red);}}); Button3.addActionListener (new executor () {public zero action action (ActionEvent evt) {textbox.setText ("Yellow"); textbox.setForeground (Color.yellow);}}); }}
You can use HTML applet tag. Something like this
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Applet code = "color square" width = "350" height = "350" & gt; & Lt; / Applet & gt; & Lt; / Body & gt; & Lt; / Html & gt;
However, some changes need to be made to your code so that it can be displayed as an applet. Currently, your code is USB frame, it should be changed to applet. Second, you need to remove f.setSize () and f.setvisible () methods
Comments
Post a Comment