ive been having a hard time figuring out my problem and i think its time to let this problem out to the world. im trying to call a certain html file to be shown on a certain frame of another html file, after a Java-made button is clicked.
to clear things out, here's the code:
Code:import java.applet.*; import java.net.*; import java.awt.*; import javax.swing.*; import javax.swing.AbstractButton; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.ImageIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; public class TestHomeButton extends Applet implements ActionListener { JButton homeButton; JPanel panel; AppletContextAdapter fetchURL = new AppletContextAdapter(); public void init( ) { setLayout(new BorderLayout( )); setBackground(Color.white); homeButton = new JButton("Home"); homeButton.setVerticalTextPosition(AbstractButton.CENTER); homeButton.setHorizontalTextPosition(AbstractButton.CENTER); homeButton.setToolTipText("History & Introduction"); homeButton.setActionCommand("home"); homeButton.addActionListener(this); add("Center", homeButton); } public void start( ) { System.out.print("Applet starting."); } public void stop( ) { System.out.print("Applet stopping."); } public void destroy( ) { System.out.print("Destroy method called."); } public void actionPerformed(ActionEvent e) { try { // URL myUrl = new URL("simple.htm"); if ("home".equals(e.getActionCommand( ))) fetchURL.showDocument(new URL("simple.htm"),"ButtonResults"); AppletContext.showDocument(new URL("simple.htm"),"ButtonResults"); } catch(Exception exept) { } }
the code above is good for one button only. i have made a dozen of these but im just testing one button for now to get the solution right.. the other would be later...
here's the (main) html file...
Code:<html> <head> <title> SKI group </title> </head> <body background="bg_fade.gif"> <center><table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td colspan=11><br></td> </tr> <tr> <td colspan=11><br></td> </tr> <tr> <td width=25><br></td> <td width=50 align="center"><img src="house.jpg" width=60 height=50 ></td> <td width=25><br></td> <td width=50 align="center"><img src="puzzle.jpg" width=60 height=50 ></td> <td width=25><br></td> <td width=50 align="center"><img src="gears01.jpg" width=60 height=50 ></td> <td width=25><br></td> <td width=50 align="center"><img src="maze.jpg" width=60 height=50 ></td> <td width=25><br></td> <td width=50 align="center"><img src="peoplemove.jpg" width=60 height=50 ></td> <td width=25><br></td> </tr> <tr> <td width=25><br></td> <td width=50 align=center><applet code="TestHomeButton.class" width=120 height=40> </applet></td> <td width=25><br></td> <td width=50 align=center><applet code="TestVariablesButton.class" width=120 height=40></applet></td> <td width=25><br></td> <td width=50 align=center><applet code="TestOperatorsButton.class" width=120 height=40></applet></td> <td width=25><br></td> <td width=50 align=center><applet code="TestFunctionsButton.class" width=120 height=40></applet></td> <td width=25><br></td> <td width=50 align=center><applet code="TestCrewButton.class" width=120 height=40></applet></td> <td width=25><br></td> </tr> <tr> <td colspan=11><br></td> </tr> <tr> <td colspan=12> <iframe name="ButtonResults" src="welcome.htm" width="700" height="500" scroll="0" frameborder="0"> </iframe> </td> </tr> </table></center> </body> </html>
so, once homeButton is clicked it calls on another html file to be shown inside the iframe... unfortunately, it just didnt work![]()
i am hoping you guys here could help me out and enlighten me...
thanks, in advance



Reply With Quote

