2012-05-23 25 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」在新的未命名的頂層窗口中顯示。

相關問題