2012-05-23 26 views
0

我已经创建了一个我想在web浏览器上运行的applet。该小程序包含发送电子邮件和使用URI打开另一个小程序等功能。在浏览器上使用的java applet的许可

该接口工作正常。但是,这些部分似乎需要一个许可,但是,

........................................................... 
    //creating session 
    Session session = Session.getDefaultInstance(props, null); 
    MimeMessage message = new MimeMessage(session); 
    message.setFrom(new InternetAddress(from)); 

    // to add recipients 
    InternetAddress[] toAddress = new InternetAddress[to.size()]; 

    // To get the array of recipients addresses 
    for(int i=0; i < to.size(); i++) { 
     toAddress[i] = new InternetAddress(to.get(i)); 
    } 
    System.out.println(Message.RecipientType.TO); 

    //adding recipients 
    for(int i=0; i < toAddress.length; i++) { 
     message.addRecipient(Message.RecipientType.TO, toAddress[i]); 
    } 
    message.setSubject(subject); 
    message.setText("This is Zaid's app"); 


    // check if animation was selected 
    if(animation) 
    fileName= attachment +".gif"; 
    else 
    fileName = attachment +".JPEG"; 

    //add the attachment 
    MimeBodyPart attachMent = new MimeBodyPart(); 
    FileDataSource dataSource= new FileDataSource(new File("ScaryImages//"+ fileName)); 
    attachMent.setDataHandler(new DataHandler(dataSource)); 
    attachMent.setFileName(fileName); 
    attachMent.setDisposition(MimeBodyPart.ATTACHMENT); 
    Multipart multipart = new MimeMultipart(); 
    multipart.addBodyPart(attachMent); 
    message.setContent(multipart); 


    //this is the sender variable 
    Transport transport = session.getTransport("smtp"); 

    //trying to send... 
    try{ 
    System.out.println("connecting..."); 
    transport.connect(host, from, pass); 

    System.out.println("sending...Please wait..."); 
    transport.sendMessage(message, message.getAllRecipients()); 
    transport.close(); 
    System.out.println("sent"); 

    JOptionPane.showMessageDialog(null,"Your Email has been sent successfully!"); 
    } 

    catch(Exception e) 
    { 
     //exception handling, the problem is mainly the connection 
     JOptionPane.showMessageDialog(null,"Connection Problem has been detected! Please Try again."); 
     e.printStackTrace(System.out); 

    } 

    //remove loading label anyway 
    finally{ 

     EmailApplet.removeLoadingLabel(); 
    } 
    ....................... 

也是这个,

尝试{

 java.net.URI uri = new java.net.URI(arg); 
     desktop.browse(uri); 
    } 

能否请你告诉我,我应该提供什么样的权限和?谢谢

回答

0

如果你想打开一个新页面,在另一个选项卡或窗口,试试这个:

getAppletContext().showDocument(url.toURI(), "_blank"); 

“_self”显示在包含applet的窗口和框架。
“_parent”显示在小程序的父框架中。如果没有父框架,则与“_self”相同。
“_top”显示在小程序窗口的顶层框架中。如果applet的框架是顶层框架,则与“_self”相同。
“_blank”在新的未命名的顶层窗口中显示。

相关问题