Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Applet

  Asked By: Madison    Date: Dec 02    Category: Java    Views: 593
  

below is a programme which is not showing the html page when button
is clicked. Please help
**********************************************************************


import java.awt.event.*;
import java.net.*;

/*
<applet code="NewWnd.class" width=250 height=250></applet>
*/

public class NewWnd extends Applet implements ActionListener
{
Button bClick;
public void init()
{
bClick=new Button("Click me");
add(bClick);
bClick.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==bClick)
{
AppletContext ac=getAppletContext();

URL url=getCodeBase();
try{
ac.showDocument(new URL
(url+"Login1.html"),"_blank");
showStatus(url.toString());
}catch(MalformedURLException e)
{
showStatus("URL not found");
}

}
}
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Viheke Fischer     Answered On: Dec 02

The modified program. Try this one ...

import java.awt.event.*;
import java.net.*;
//add this one to your program
import java.applet.*;
import java.awt.*;

public class  NewWnd extends applet  implements ActionListener
{
Button bClick;
public void  init()
{
bClick=new Button("Click me");
add(bClick);
bClick.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==bClick)
{
AppletContext ac=getAppletContext();

URL url=getCodeBase();
try {
ac.showDocument(new URL
(url+"Login1.html"),"_blank");
showStatus(url.toString());
}
// I change the exception
catch(Exception e)
{
showStatus("URL not found");
}

}
}
}

 
Didn't find what you were looking for? Find more on Applet Or get search suggestion and latest updates.




Tagged: