Results 1 to 1 of 1
  1. #1
    cfc1252 is offline Member
    Join Date
    Jan 2012
    Posts
    11
    Rep Power
    0

    Default Image and Hyperlink issues (JEditorPane

    First thing when i copy and paste the output of my JDailog (What this textpane is displayed on), the image is coming out with "ignored text" How can I get it to copy the image?

    Second problem: I want the variable regLink to be a hyperlink. How can I do this?

    Here is my code:

    Java Code:
               
                String fName = jt_fName.getText(); 
                String lName = jt_lName.getText(); 
                String telNet = jt_telNet.getText();
                String telPhone = jt_telPhone.getText();
                String mobPhone = jt_mobPhone.getText();
                String role = jt_role.getText();
                String img = jt_imgBanner.getText(); 
                String regLink = jt_regLink.getText();
                String regText = jt_regText.getText();
                
                // Get the text pane's document
                JTextPane textPane = new JTextPane();
                textPane.setEditable(false); 
                StyledDocument doc = (StyledDocument)textPane.getDocument();
                javax.swing.text.Style style2 = doc.addStyle("StyleName", null);
    
                // The image must first be wrapped in a style
                javax.swing.text.Style style = doc.addStyle("StyleName", null);
                StyleConstants.setIcon(style, new ImageIcon(img));
    
                // Insert the image at the end of the text
                try {
                	doc.insertString(doc.getLength(),fName  + lName + "\n" + "Role: " + role + "\n" +
                            "Telnet: " + telNet + "\n" + "Telphone Number: " + telPhone + "\n" + 
                            "Mobile Number: " + mobPhone + "\n", style2);
                	doc.insertString(doc.getLength(), "ignored text", style);
                	doc.insertString(doc.getLength(), "Register Here: " + regLink + " | " + regText, style2);
    			} catch (BadLocationException e1) {
    				// TODO Auto-generated catch block
    				e1.printStackTrace();
    			}
    Last edited by cfc1252; 09-14-2012 at 05:47 PM.

Similar Threads

  1. Having issues with drawing portion of an image
    By 7H3LaughingMan in forum Java 2D
    Replies: 2
    Last Post: 05-03-2012, 06:50 AM
  2. Image issues
    By Toll in forum Advanced Java
    Replies: 7
    Last Post: 05-20-2011, 04:38 AM
  3. Getting the hyperlink URL
    By leifster in forum New To Java
    Replies: 1
    Last Post: 11-27-2010, 05:01 PM
  4. How to display image in JEditorPane
    By usccar in forum New To Java
    Replies: 1
    Last Post: 12-10-2009, 06:34 AM
  5. Hyperlink in swing
    By aneesahamedaa in forum AWT / Swing
    Replies: 1
    Last Post: 07-28-2008, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •