Results 1 to 8 of 8
  1. #1
    danz is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default Tooltip HTML format problem

    I am using an HTML formatted tool tip on a JButton.
    All is fine the first time I launch my applet.
    However, if I close the Applet browser window and re-launch, the tool tip is blank.
    This is only for <html> formatted text, non-HTML strings are fine.
    It is not browser specific (same behavior for IE,FF,SF,etc).
    Is this a known problem, or maybe I'm missing something?

    example:
    btn.setToolTipText("<html>does not work after re-launch</html>");
    btn.setToolTipText("works fine after re-launch");

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    Hard to understand how a program will work one time and then not another.
    Is there a difference when you load the html page in the browser between the time it works and the time it doesn't work?
    Or is this a case of you moving off the html page with the applet and coming back to it?
    The applet has methods that are called when that happens.

  3. #3
    danz is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    I'm not doing anything funky. The HTML <APPLET> tags is also quite generic

    Java Code:
    <APPLET 
       ARCHIVE  = "/java/test/MyApplet.jar" 
       CODE     = "test/MyApplet.class"
       NAME     = "test" 
       HEIGHT   = "100%"
       WIDTH    = "100%"
       MAYSCRIPT >
    </APPLET>
    Java Code:
    package test;
    
    import java.awt.event.*;
    import javax.swing.*;
    
    public class MyApplet extends javax.swing.JApplet implements Runnable {
    
        public static final long serialVersionUID = 1L;           
        
        private final String TT_HTML       = "<html>HTML</html>";
        private final String TT_NON_HTML   = "NonHTML";
    
    
        /** Initializes the MyApplet */
        public void init() {
            initComponents();
        }
        
        public void start(){
            updateBtnControl();
        }
        
        public void run() {
        }
    
        private void updateBtnControl() {
          String tt = btnControl.getToolTipText();
    
          if ((tt==null) || (tt.equalsIgnoreCase(TT_HTML))) {
    
            btnControl.setToolTipText(TT_NON_HTML);
          }
          else {
            btnControl.setToolTipText(TT_HTML);
          }
        }
    
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
    
            btnControl = new javax.swing.JButton();
    
            btnControl.setFocusable(false);
            btnControl.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
            btnControl.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
            btnControl.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnControlActionPerformed(evt);
                }
            });
            getContentPane().add(btnControl, java.awt.BorderLayout.CENTER);
        }// </editor-fold>
                        
        private void btnControlActionPerformed(java.awt.event.ActionEvent evt) {                                           
          updateBtnControl();
        }                                          
    
        // Variables declaration - do not modify
        private javax.swing.JButton btnControl;
        // End of variables declaration
        
    }

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    What's supposed to happen when the applet is loaded in a browser?
    I get a full screen button with no text.
    Then what?

  5. #5
    danz is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    Norm;

    Yes, that sounds about right.
    I stripped my Applet down to bare bones for demonstration purposes.
    You are looking at a big button with no text or icon.
    The tool tip toggles every time to click this button (after a mouse over).
    You should notice that the tool tip will toggle between "HTML" and "NonHTML".
    If you kill the browser and relaunch, the "HTML" tool tip goes away.

    I am also creating my window something like;
    javascript:void(window.open(\"/launch.html\",\"1062731320\",\"status=yes,scrollba rs=yes,resizable=yes,menubar=no,toolbar=no,directo ries=no,location=no,width=700,height=500\"))

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    Have you added printlns to all the methods and the constructor to see when they are called?

    I get the second TT sometimes as a short dark blue line vs the text.

    When I changed this variable I get the full text:

    private final String TT_HTML = "<html>HTML that is longer than the other one</html>";
    Last edited by Norm; 07-14-2011 at 11:04 PM.

  7. #7
    danz is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    I always get the "short dark blue line vs the text" (:

    So you are able to reproduce the error?

    It is odd that it works for you after increasing TT_HTML variable.

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

Similar Threads

  1. output format problem.
    By jim01 in forum New To Java
    Replies: 8
    Last Post: 04-18-2011, 09:00 AM
  2. Format editing in HTML view with JEditorPane
    By peterme in forum Advanced Java
    Replies: 4
    Last Post: 02-23-2011, 09:05 PM
  3. Tooltip problem with two monitors
    By rogerbacon in forum New To Java
    Replies: 6
    Last Post: 07-12-2010, 03:38 PM
  4. Problem to ToolTip in Java 3d
    By roshithmca in forum AWT / Swing
    Replies: 1
    Last Post: 02-05-2008, 03:46 AM
  5. Problem with '/' character in HTML and JSP
    By Marcus in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2007, 05:32 AM

Posting Permissions

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