Tooltip in JTextField

This is my problem. I have a JTextField and I have to turn on a tooltip which must show the current text of the JTextField. This tooltip should be turned on only if the text is not completely visible in the text field.
I'm not able to test if the text is completely visible or not.
Thanks in advance,
     Rossella

Well... how can I verify whether the height of the total text is bigger than the height of the area? The method getRowHeight() is protected :o(
The user can dicided to have scroll bars or not, to show tooltips or not (and he can decide to show always the text in the tooltip, or to show it only if it is not completely visible). So I must implement this tooltip even though then the user could decide to add scroll bars to the area.
Thanks,
Rossella

Similar Messages

  • Strange behaviour whit custom JTextField and JToolTip

    Hello everyone. I hope I'm writing in the right section and sorry if I did not search for this issue but I really don't know which keywords I should use.
    I'm using NetBeans 6.1 on WinXP and JDK 1.6.0_07, I have a custom JTextField with regex validation: when you type something that don't mach regex it shows a JToolTip. This JToolTip should disappear when the text typed is finally correct, or when the textfield loses focus (see code below).
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Point;
    import javax.swing.JToolTip;
    import javax.swing.Popup;
    import javax.swing.PopupFactory;
    public class MyJTextField extends javax.swing.JTextField implements FormComponent
    private static Popup popUpToolTip;
    private static PopupFactory popUpFactory = PopupFactory.getSharedInstance();
    private boolean isValidated = false;
    private String regEx = "a regex";
    public MyJTextField()
    this.addKeyListener(new java.awt.event.KeyAdapter()
    public void keyReleased(java.awt.event.KeyEvent evt)
    if(evt.getKeyCode()!=java.awt.event.KeyEvent.VK_ENTER)
    validateComponent();
    else if(evt.getKeyCode()==java.awt.event.KeyEvent.VK_ENTER)
    if(isValidated)
    ((Component)evt.getSource()).transferFocus();
    this.addFocusListener(new java.awt.event.FocusAdapter()
    public void focusLost(java.awt.event.FocusEvent evt)
    if(popUpToolTip!=null){popUpToolTip.hide();}
    public void validateComponent()
    if(text.matches(regex))
    isValidated = true;
    if(popUpToolTip!=null){popUpToolTip.hide();}
    else
    isValidated = false;
    if(popUpToolTip!=null){popUpToolTip.hide();}
    String error = "C'è un errore nella validazione di questo campo";
    JToolTip toolTip = createToolTip();
    toolTip.setTipText(error);
    popUpToolTip = null;
    popUpToolTip = popUpFactory.getPopup(
    this,
    toolTip,
    getLocationOnScreen().x,
    getLocationOnScreen().y - this.getPreferredSize().height -1
    popUpToolTip.show();
    }(I've cut it a bit, here's only the lines that involve JToolTip use)
    I have many of them in a form, and when the first tooltip appears (on the first textfield I type in) it never disappears, while nex textfields work just fine.It seems the first tooltip appearing can't be overwritten or something similar. If I use this same component on any other NetBeans project, everithing works without issues.
    I have some other custom components working the same way (JComboBox, JXDatePicker), and they had this "not disappearing tooltip" issue since I changed this
    popUpToolTip = popUpFactory.getPopup(this, toolTip, getLocationOnScreen().x, getLocationOnScreen().y - this.getPreferredSize().height -1);
    whit this
    popUpToolTip = popUpFactory.getPopup(null, toolTip, getLocationOnScreen().x, getLocationOnScreen().y - this.getPreferredSize().height -1);
    but if I try it on the JTextField all textfield's tooltips stay stuck there, not only the first one appeared (while other components still works fine).
    This thing is really driving me crazy. Someone has an hint (or a link to another thread) which could explain this strange behaviour?
    Thanks in advance.

    BoBear2681 wrote:
    Note that an SSCCE wouldn't require you to post any proprietary code.Hmmm... well, I'll try again to reproduce the issue and post an SSCCE.
    BoBear2681 wrote:
    That probably indicates that the problem is somewhere other than where you're currently looking.Yes, I suppose so. Maybe it's some interference between all the custom components I created, or maybe something else that apparently doesn't conern at all. If I cannot reproduce it in an SSCCE and I'll figure out what's the cause of this mess I'll post it here for future knowledge.
    Many thanks for your advices. :)

  • Always show  tooltip

    Hi!
    I have a text field and tooltip assign to it. When I entering the text tooltip is show. Whether there is a way to show tooltip always? Only I move mouse or lost focus on text field the tooltip is hide.
    Thank you.

    Test this code and tell me if it is ok for you :
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class TestToolTipTextField extends JTextField {
         Random r =new Random(System.currentTimeMillis());
         JButton b;
         ToolTipManager manager = ToolTipManager.sharedInstance();
         public TestToolTipTextField() {
              super(20);
              manager.setInitialDelay(0);
             //setToolTipText("");
              setPreferredSize(new Dimension(200,20));
              addCaretListener(new CaretListener() {
                   public void caretUpdate(CaretEvent e) {
                        Caret c = getCaret();
                        if (c!= null && hasFocus()) {
                             Point p = c.getMagicCaretPosition();
                             showToolTip(p);                         
         public void showToolTip(Point p) {
              MouseEvent e;
              if (p!= null) {
                   e = new MouseEvent(this, MouseEvent.MOUSE_MOVED, 0, 0,(int)p.getX(),(int)p.getY(),0,false);               
              else {
                   e = new MouseEvent(this, MouseEvent.MOUSE_MOVED, 0, 0,0,0,0,false);     
              manager.mouseMoved(e);
         public String getToolTipText(MouseEvent e) {
              return("Position : ("+e.getX()+","+e.getY()+")");
         public static void main(String[] args) {
              JFrame f = new JFrame("Frame");
              TestToolTipTextField t = new TestToolTipTextField();
              f.getContentPane().add(t, BorderLayout.CENTER);
              f.pack();
              f.setVisible(true);
    }The same without formatting :
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class TestToolTipTextField extends JTextField {
         Random r =new Random(System.currentTimeMillis());
         JButton b;
         ToolTipManager manager = ToolTipManager.sharedInstance();
         public TestToolTipTextField() {
              super(20);
              manager.setInitialDelay(0);
         //setToolTipText("");
              setPreferredSize(new Dimension(200,20));
              addCaretListener(new CaretListener() {
                   public void caretUpdate(CaretEvent e) {
                        Caret c = getCaret();
                        if (c!= null && hasFocus()) {
                             Point p = c.getMagicCaretPosition();
                             showToolTip(p);                         
         public void showToolTip(Point p) {
              MouseEvent e;
              if (p!= null) {
                   e = new MouseEvent(this, MouseEvent.MOUSE_MOVED, 0, 0,(int)p.getX(),(int)p.getY(),0,false);               
              else {
                   e = new MouseEvent(this, MouseEvent.MOUSE_MOVED, 0, 0,0,0,0,false);     
              manager.mouseMoved(e);
         public String getToolTipText(MouseEvent e) {
              return("Position : ("+e.getX()+","+e.getY()+")");
         public static void main(String[] args) {
              JFrame f = new JFrame("Frame");
              TestToolTipTextField t = new TestToolTipTextField();
              f.getContentPane().add(t, BorderLayout.CENTER);
              f.pack();
              f.setVisible(true);
    I hope this helps,
    Denis

  • How to show ToolTip on FocusGained event

    Situation is like following:
    A JTextField has some ToolTip associated with it, I want to show that ToolTip on FocusGained event of that JTextField.

    Here it is (note that resource is simply a class file that contains color and font settings -- nohting mysterious):
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class ToolTip extends Canvas {
       protected String tip;
       protected Component owner;
       private Container mainContainer;
       private LayoutManager mainLayout;
       private boolean shown;
       private int VERTICAL_OFFSET,HORIZONTAL_OFFSET,X,Y;
       private final int HORIZONTAL_ENLARGE=10;
       private FontMetrics fm;
       public ToolTip(String tip, Component owner, Container mc, int bp, resource res) {
          this.tip=tip;
          this.owner=owner;
          this.mainContainer=mc;
          setBackground(res.ToolTipBGColor);
          setForeground(res.ToolTipFGColor);
          setFont(res.ToolTipFont);
          fm=getFontMetrics(getFont());
          X=owner.getLocationOnScreen().x;
          Y=owner.getLocationOnScreen().y;
          int w=owner.getSize().width;
          int h=owner.getSize().height;
          if (bp==0) {                         // top
             HORIZONTAL_OFFSET=3;
             VERTICAL_OFFSET=h;
          } else if (bp==1) {                  // left
             HORIZONTAL_OFFSET=w;
             VERTICAL_OFFSET=0;
          } else if (bp==2) {                  // right
             HORIZONTAL_OFFSET=-fm.stringWidth(tip)-HORIZONTAL_ENLARGE;
             VERTICAL_OFFSET=0;
          } else {                             // bottom
             HORIZONTAL_OFFSET=3;
             VERTICAL_OFFSET=-fm.getHeight();
          owner.addMouseListener(new MAdapter());
       public void paint(Graphics g) {
          g.drawRect(0,0,getSize().width,getSize().height);
          g.drawString(tip,3,getSize().height-3);
       private void addToolTip() {
          mainContainer.setLayout(null);
          setSize(fm.stringWidth(tip)+HORIZONTAL_ENLARGE, fm.getHeight());
          setLocation(X-mainContainer.getLocationOnScreen().x+HORIZONTAL_OFFSET,
             Y-mainContainer.getLocationOnScreen().y+VERTICAL_OFFSET);
          if (mainContainer.getSize().width<(getLocation().x+getSize().width)) {
             setLocation(mainContainer.getSize().width-getSize().width, getLocation().y);
          mainContainer.add(this,0);
          mainContainer.validate();
          shown=true;
       private void removeToolTip() {
          if (shown) {
             mainContainer.remove(0);
             mainContainer.setLayout(mainLayout);
             mainContainer.validate();
          shown = false;
       class MAdapter extends MouseAdapter {
          public void mousePressed(MouseEvent me) {
             if (me.getModifiers()==4) {
                mainLayout=mainContainer.getLayout();
                addToolTip();
                me.consume();
          public void mouseReleased(MouseEvent me) {
             if (shown) removeToolTip();
    }If you have problem modifying the code, noah.w is an expert in the GUI stuff, maybe he can help you.
    Hope this helps!
    ;o)
    V.V.

  • JTextField & ToolTipText

    Hello,
    I need some help. I create a JTextField where the content of the text pane have to respect a model. The model is selected by a JComboBox. I want that the ToolTipText shows the skeleton of the selected model.
    Every time I change the selection, I change the content of the ToolTipText but I always see the first text put in the ToolTipText. How can I see the change ?

    I have no idea where the model fits into this
    I have no idea how the text pane fits into thisimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JFrame {
      String[] data = {"One","Two","Three"};
      JComboBox jcb = new JComboBox(data);
      JTextField jtf = new JTextField("Something");
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.setLayout(new FlowLayout());
        content.add(jcb);
        jtf.setToolTipText("Some Tooltip");
        content.add(jtf);
        jcb.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            jtf.setToolTipText(jcb.getSelectedItem().toString()+" Tooltip");
        setSize(300, 300);
        show();
      public static void main(String[] args) { new Test(); }
    }

  • Multiple tooltips at once

    I have an application that uses a JPanel with multiple JLabels in it. Each JLabel has a ToolTip to display. I would like to implement a button that when clicked, displays all ToolTips at once. Any ideas on how to do this?
    Bonus: If not by default, the ToolTips should be arranged, if possible, in a way so that they do not overlap each other. (5 Duke dollars)

    WARNING!!! This is a hack! I had a theory that I could drag code out of TooltipManager and display the tooltips. It worked, however, this is just test code. I paid very little attention to figuring out what every piece of code did. I commented out some pieces and created some variables where they were undefined. You should probably redo what I did and put a little more thought into it. Anyways, here it is.import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.ArrayList;
    public class Test extends JFrame  {
      Container content = getContentPane();
      ArrayList tips = null;
      public Test() {
        super("Test");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel jp = new JPanel(new FlowLayout());
        content.add(jp, BorderLayout.CENTER);
        JTextArea jta = new JTextArea("Four score and seven years ago");
        jta.setWrapStyleWord(true);
        jta.setLineWrap(true);
        JScrollPane jsp = new JScrollPane(jta);
        jsp.setPreferredSize(new Dimension(100,100));
        jta.setToolTipText("Abe Lincoln");
        jp.add(jsp);
        JTextField jtf = new JTextField("Inna Gadda Da Vida");
        jtf.setToolTipText("Iron Butterfly");
        jp.add(jtf);
        JButton jb = new JButton("Tooltips");
        content.add(jb, BorderLayout.SOUTH);
        jb.addMouseListener(new MouseAdapter() {
          public void mousePressed(MouseEvent me) {
            tips = getAllToolTips(content, new ArrayList());
            for (int i=0; i<tips.size(); i++) {
              ((Popup)tips.get(i)).show();
          public void mouseReleased(MouseEvent me) {
            for (int i=0; i<tips.size(); i++) {
              ((Popup)tips.get(i)).hide();
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] args) { new Test(); }
      public ArrayList getAllToolTips(Container c, ArrayList al) {
        Component[] comps = c.getComponents();
        for (int i=0; i<comps.length; i++) {
          if (comps[i] instanceof JComponent) {
            String s;
            if (comps.isShowing() && comps[i].isEnabled() &&
    comps[i] instanceof JComponent &&
    (s=((JComponent)comps[i]).getToolTipText())!=null) {
    JToolTip tip = ((JComponent)comps[i]).createToolTip();
    tip.setTipText(s);
    MouseEvent mouseEvent = new MouseEvent(comps[i], 0, 0, 0, 0,0,1,false,0);
    Point screenLocation = comps[i].getLocationOnScreen();
    Point location = new Point();
    Rectangle sBounds = comps[i].getGraphicsConfiguration().
    getBounds();
    boolean leftToRight = true;//SwingUtilities.isLeftToRight(comps[i]);
    Dimension size = tip.getPreferredSize();
    Point preferredLocation = ((JComponent)comps[i]).getToolTipLocation(mouseEvent);
    if(preferredLocation != null) {
    location.x = screenLocation.x + preferredLocation.x;
    location.y = screenLocation.y + preferredLocation.y;
    if (!leftToRight) {
    location.x -= size.width;
    } else {
    location.x = screenLocation.x + mouseEvent.getX();
    location.y = screenLocation.y + mouseEvent.getY() + 20;
    if (!leftToRight) {
    if(location.x - size.width>=0) {
    location.x -= size.width;
    // we do not adjust x/y when using awt.Window tips
    // if (!heavyWeightPopupEnabled){
    Rectangle popupRect=null;
    if (popupRect == null){
    popupRect = new Rectangle();
    popupRect.setBounds(location.x,location.y,
    size.width,size.height);
    int y = getPopupFitHeight(popupRect, comps[i]);
    int x = getPopupFitWidth(popupRect,comps[i]);
    if (y > 0){
    location.y -= y;
    if (x > 0){
    // adjust
    location.x -= x;
    // Fit as much of the tooltip on screen as possible
    if (location.x < sBounds.x) {
    location.x = sBounds.x;
    else if (location.x - sBounds.x + size.width > sBounds.width) {
    location.x = sBounds.x + Math.max(0, sBounds.width - size.width)
    if (location.y < sBounds.y) {
    location.y = sBounds.y;
    else if (location.y - sBounds.y + size.height > sBounds.height) {
    location.y = sBounds.y + Math.max(0, sBounds.height - size.height);
    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    // if (lightWeightPopupEnabled) {
    // popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    // else {
    // popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
    Popup tipWindow;
    tipWindow = popupFactory.getPopup(comps[i], tip,
    location.x,
    location.y);
    // popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    al.add(tipWindow);
    if (comps[i] instanceof Container) getAllToolTips((Container)comps[i], al);
    return al;
    private int getPopupFitWidth(Rectangle popupRectInScreen, Component invoker){
    if (invoker != null){
    Container parent;
    for (parent = invoker.getParent(); parent != null; parent = parent.getParent()){
    // fix internal frame size bug: 4139087 - 4159012
    if(parent instanceof JFrame || parent instanceof JDialog ||
    parent instanceof JWindow) { // no check for awt.Frame since we use Heavy tips
    return getWidthAdjust(parent.getBounds(),popupRectInScreen);
    } else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
    Rectangle popupFrameRect=null;
    if (popupFrameRect == null){
    popupFrameRect = new Rectangle();
    Point p = parent.getLocationOnScreen();
    popupFrameRect.setBounds(p.x,p.y,
    parent.getBounds().width,
    parent.getBounds().height);
    return getWidthAdjust(popupFrameRect,popupRectInScreen);
    return 0;
    // Returns: 0 no adjust
    // >0 adjust by value return
    private int getPopupFitHeight(Rectangle popupRectInScreen, Component invoker){
    if (invoker != null){
    Container parent;
    for (parent = invoker.getParent(); parent != null; parent = parent.getParent()){
    if(parent instanceof JFrame || parent instanceof JDialog ||
    parent instanceof JWindow) {
    return getHeightAdjust(parent.getBounds(),popupRectInScreen);
    } else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
    Rectangle popupFrameRect=null;
    if (popupFrameRect == null){
    popupFrameRect = new Rectangle();
    Point p = parent.getLocationOnScreen();
    popupFrameRect.setBounds(p.x,p.y,
    parent.getBounds().width,
    parent.getBounds().height);
    return getHeightAdjust(popupFrameRect,popupRectInScreen);
    return 0;
    private int getHeightAdjust(Rectangle a, Rectangle b){
    if (b.y >= a.y && (b.y + b.height) <= (a.y + a.height))
    return 0;
    else
    return (((b.y + b.height) - (a.y + a.height)) + 5);
    private int getWidthAdjust(Rectangle a, Rectangle b){
    // System.out.println("width b.x/b.width: " + b.x + "/" + b.width +
    //          "a.x/a.width: " + a.x + "/" + a.width);
    if (b.x >= a.x && (b.x + b.width) <= (a.x + a.width)){
    return 0;
    else {
    return (((b.x + b.width) - (a.x a.width)) 5);

  • Displaying tooltip programmatically

    Hello,
    I found code in the forum (How to force the display of a ToolTip? for the above mentioned task. The posting is of this year, but when I try to apply the code, my toolTipAction is always null. Is there a mistake in my code or a change in jdk7?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TTTest extends JFrame {
      public TTTest() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container cp= getContentPane();
        cp.setLayout(null);
        setSize(260,300);
        final JTextField tf= new JTextField();
        tf.setToolTipText("This is the tooltip.");
        tf.setBounds(75,80,100,25);
        JButton b= new JButton("Display tooltip");
        b.setBounds(50,150,150,30);
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
         Action toolTipAction = tf.getActionMap().get("postTip");
         if (toolTipAction != null) {
           ActionEvent postTip = new ActionEvent(tf, ActionEvent.ACTION_PERFORMED, "");
           toolTipAction.actionPerformed(postTip);
         else {
    //       Since toolTipAction is null, let's inspect the map
           ActionMap map = tf.getActionMap();
           Object[] keys = map.allKeys();
           for (Object o: keys) {
    //         System.out.println(o); // Indeed, there's no "postTip" key.
             if (o.equals("postTip")) System.out.println("--- KEY FOUND! ---");
        cp.add(tf);
        cp.add(b);
        setVisible(true);
      static public void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
         new TTTest();
      }

    That's convincing. Thank you very much.
    ... why that unnecessary local field cp?I only remember that when it became possible to add components directlly to a JFrame (was it 1.5?)
    that there are still some cases when the contentPane is a must. So when testing I prefer to be on the safe side.
    In the meantime I found this way:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TTTest2 extends JFrame {
      private Popup tooltipPopup;
      public TTTest2() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new FlowLayout(FlowLayout.CENTER, 60, 60));
        setSize(260,300);
        final JTextField tf= new JTextField(10);
        final PopupFactory popupFactory = PopupFactory.getSharedInstance();
        final JToolTip toolTip = new JToolTip();
        toolTip.setTipText("This is the tooltip.");
        JButton b= new JButton("Display tooltip");
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
         tooltipPopup = popupFactory.getPopup(tf, toolTip,
                             tf.getLocationOnScreen().x +10,
                             tf.getLocationOnScreen().y +25);
    //     tooltipPopup.show(); // if you want to programmatically close the tip.
         showTooltip(3);
        add(tf);
        add(b);
        setVisible(true);
      private void showTooltip(int seconds) {
        tooltipPopup.show();
        javax.swing.Timer t= new javax.swing.Timer(seconds*1000, new ActionListener() {
          public void actionPerformed(ActionEvent e) {
         tooltipPopup.hide(); // disposes of the popup.
        t.setRepeats(false);
        t.start();
      static public void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
         new TTTest2();
    }

  • How to work out which character the mouse is over in a JTextField

    Hi everyone,
    I have a non editable JTextField which contains a string of comma separated values eg
    A, B, C, D, E
    Each of these values will have an associated decode which I want to display in a tooltip.
    I want to hover the mouse over a character in the JTextField and programmatically determine which character I am pointing at, so I can use the value to look up the decode.
    Can anybody offer me some advice on how to do this please?
    Many thanks in advance,
    Nick

    Check out the getIndexAtPoint method (here is what the API says):
             * Given a point in local coordinates, return the zero-based index
             * of the character under that Point.  If the point is invalid,
             * this method returns -1.
             * @param p the Point in local coordinates
             * @return the zero-based index of the character under Point p.
            public int getIndexAtPoint(Point p) {;o)
    V.V.

  • How do I add URI web link with custom tooltip like "CLICK HERE TO UPDATE" instead of URI web link in tooltip.

    How do I add URI web link with custom tooltip like "CLICK HERE TO UPDATE" instead of URI web link in tooltip.

    You've probably found an answer to this by now, but I think this has been addressed in another forum -- The link below suggested using a button and adding the tooltip to the button. 
    https://forums.adobe.com/thread/304974?start=0&tstart=0
    Sounds like it would work but I haven't actually tried it. 
    Good luck~!

  • Open and Close OnScreen Keyboard while focus gain on JTextField

    Hi
    I have a Jtextfield when ever I click on textfield I want to open OSK(On Screen Keyboard) of Windows 8 OS and windows 7.
    I tried in below mentioned way to open and close in focus listener focusGained() and focusLost() but it is not working. could some body do needful.
    Opening OSK:
    builder = new ProcessBuilder("cmd /c " + sysroot + " /System32/osk.exe");
    Closing Osk:
    Runtime.getRuntime().exec("taskkill /f /im osk.exe");

    You need to start() the ProcessBuilder and you need to split the command like this:
    builder  = new ProcessBuilder("cmd", "/c", sysroot + " /System32/osk.exe");
    builder.start();
    And naturally you should wrap the call in a new Thread or use an ExecutorService to avoid EDT problems.

  • Can we have a Single quote in the tooltip text?

    Hi,
    We have some tooltips for the presentation columns which contains a single quote.
    When I try to view the tooltip from answers the single quote is being replaced by double quotes.
    I tried to use all sorts of escape characters for single quote, like "\'" and ''' and "'" but that didn't work.
    Is there any way to do this.
    Thanks!!
    Vasantha.P

    As I said in my earlier post, I am looking for the tooltips for the Presentation tables and columns. The tooltips for these were extracted from the RPD using the externalize Strings option and these externalized strings are stored in the database.
    So I am escaping the single using a single quote both in rpd and in the database.
    Example text I have used both in the rpd and database is something like "Shipment's start time". I tried with "Shipment''s start time", " Shipment'''s start time", but it didn't work.
    Thanks!!
    Vasantha.P

  • Using a variable in Spry conditional tests included in a Spry Tooltip

    I have the following code:
    <div spry:region="company" id="tooltip">
    <div spry:repeat="company" spry:choose="spry:choose">
    <div spry:when="'{name}'==memberName">
    <table>
    <tr>
    <td
    align="center"><h2>{name}</h2></td>
    </tr>
    <tr>
    <td align="center"><img src="{headshot}"
    alt="{name}" width="227" height="350" /></td>
    </tr>
    <tr>
    <td align="center">{description}</td>
    </tr>
    </table>
    </div>
    </div>
    </div>
    <script type="text/javascript">
    var tooltip_trigger_one = new
    Spry.Widget.Tooltip("tooltip","#trigger", {showDelay: 200,
    hideDelay: 200, offsetX: 250, offsetY: 200} );
    </script>
    where the variable "memberName" is set elsewhere to a value
    that matches one of the occurrences in the column "name" in the
    dataset "company". I can see, using debugging tools, that the
    variable is being set correctly. But.... when the tooltip is
    triggered, only a small few-pixel square box opens up.
    If, instead of using the variable "memberName" in:
    <div spry:when="'{name}'==memberName">
    I use a string, as in
    <div spry:when="'{name}'=='John Doe'">
    then the code works correctly and I get a large tootlip
    showing me the correct information for that member of the company.
    I have tried different tests (spry:if and spry:test for
    instance), tried various combinations of quotes and parenthesis and
    tried placing the code at various places both inside and outside of
    the <body> -- but always get the same results.
    Is it not possible to test against a variable or am I doing
    something else incorrectly?
    Thanks,
    Janet

    OK.... some progress to report.
    I was setting memberName onmouseover-- which is also the
    trigger for the tooltip-- thusly:
    <p><em onmouseover="memberName='John Doe'"
    id="trigger">John Doe</em></p>
    It seems that the variable is being set, but too late, as the
    trigger has already caused the div... id="tooltip"> to be
    evaluated with "memberName" not equal to any of the names in the
    dataset. I tried using a function call to set "memberName" and
    tried putting the onmouseover in the <p> tag and leaving the
    trigger id in the <em> tag. but neither of those appear to
    change the outcome. "memberName" still appears to be set to the
    value I initialized it to up the the <head> section at the
    time the tooltip <div> is evaluated. Although it is set
    correctly if I check it's value using Firebug after I have
    mouse-overed it.
    Incidentally, using a Firebug breakpoint just before the
    <div spry:when...> and checking the value of memberName was
    how I discovered that "memberName" still seemed to have a value of
    "initialized" which is what I set it to up in the <head>
    section.
    Having written all of this, I am wondering though, shouldn't
    the value of "memberName" be equal to "John Doe" the second time I
    mouseover it? Or, if there are more than one trigger "names" on the
    page, shouldn't "memberName" be equal to the name of the previous
    trigger that I moused-over? And with memberName having a legitimate
    value at that point, shouldn't the tooltip now show the correct
    display information rather than just that little few pixel square
    box that I am getting when I mouse-over the trigger name?
    Clearly there is something that I just am not understanding.
    Janet

  • Dreamweaver adding div height in tooltip?

    I dont normally use dreamweaver, but I must for this project,
    in dreamweaver for some bizarre reason the tooltip says height 50px
    (54px) and has added 4pxs to an image in a div. Anyone know why? It
    aligns in the browsers, IE 6, firefox, but why has dreamweaver
    added these 4 pixels and given it a gap in dreamweaver?
    Picture example:
    http://homepage.ntlworld.com/spensley/dreamweaverbug.jpg
    anyone know why and what this is all about?
    The css:
    #logo{
    top: 30px;
    width:126px;
    height: 51px;
    padding:0px;
    float: left;
    html:
    <div id="logo"><a href="index.html"><img
    src="media/images/gtfLogo.jpg" title="GTF logo" alt="GTF logo
    design" longdesc="three circles showing the letters G, T and F in
    orange and green" width="126"
    height="51"/><a/></div>

    Oops - sorry - missed the CSS.
    You have a munged <a> tag -
    orange and green" width="126" height="51"/><a/></
    should be -
    orange and green" width="126" height="51"/></a></
    Does that solve the problem?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "spongebobcirclepants" <[email protected]>
    wrote in message
    news:[email protected]...
    > <?xml version="1.0" encoding="utf-8"?>
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Strict//EN"
    > "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    > <html xmlns="
    http://www.w3.org/1999/xhtml"
    xml:lang="en" lang="en">
    > <head>
    > <title>GTF - Gardens, Tools &
    Furniture</title>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8" />
    > <meta name="keywords"
    >
    content="tools,gardens,furniture,spades,water,toys,toy,gardening,uk,giant
    >
    toys,giant,lawnmowers,tool,diy,outdoor,outdoors,pool,shovels,hoses,hose,fish,aqu
    > atics,benches,tables,chairs" />
    > <meta name="description" content="GTF Company Site"
    />
    > <meta name="author" content="Roy Spensley" />
    >
    > <link rel="stylesheet" type="text/css"
    href="style/textformat.css"/>
    > <link rel="stylesheet" type="text/css"
    href="style/layout.css"
    > title="default"
    > />
    >
    > </head>
    >
    > <div id="wrapper">
    >
    > <div id="topSpace"></div>
    > <div id="logo"><a href="index.html"><img
    src="media/images/gtfLogo.jpg"
    > title="GTF logo" alt="GTF logo design" longdesc="three
    circles showing the
    > letters G, T and F in orange and green" width="126"
    > height="51"/><a/></div>
    > <div id="logoRight"></div>
    > </div>
    > </body>
    > </html>
    >
    >
    > css
    >
    >
    >
    > /*BODY*/
    >
    > body{
    >
    > margin-top:0px;
    >
    > margin:0px;
    >
    > left:0px;
    >
    > padding:0px;
    >
    > font-family: arial, Helvetica, sans-serif;
    >
    > font-size: 100.1%;/*fixes bug in IE*/
    >
    > color:#333333;
    >
    > text-align: center;
    >
    > background-color: #666666;
    >
    > overflow: auto;
    >
    > }
    >
    > /*ALL IMAGES*/
    >
    > img{
    >
    > border-style: none;
    >
    > }
    >
    >
    > /*CONTAINING WRAPPER*/
    >
    > #wrapper{
    >
    > width: 800px;
    >
    > margin-top: 0px;
    >
    > height: 597px;
    >
    > background-color: #000;
    >
    > margin: 0 auto; /*This will now centre in firefox as
    well*/
    >
    > }
    >
    > #topSpace{
    >
    > width: 100%;
    >
    > height: 30px;
    >
    > padding:0px;
    >
    > background-color: #fff;
    > }
    >
    > #logo{
    >
    > top: 30px;
    >
    > width:126px;
    >
    > height: 51px;
    >
    > padding:0px;
    >
    > float: left;
    >
    > }
    >

  • ToolTip positioning and volume 'hit' area problem

    Hello,
    I have been working on re-skinning the player that comes with Adobe's FMS, in flex builder 3 and I would really appreciate some help on the following issues.
    1. Positioning the tooltips. I have figured out how to change the style of these (text, background opacity etc) via the embedStyle.css, no problems with that. However, I just cannot figure out how to actually reposition them from the default position of the bottom right.
    2. My volume control (volume slider) sits above my progress bar on the players GUI. You can drag both of these to adjust. However, when the progress bar is under the volume bar the progress bar loose it's interactivity. The volume slider only has a height of 2, but it appears that it's actual button 'hit' area is sitting over the progress bar.
    I have do a stack of googling on these but I am still hitting a wall with it. Any help would be much appreciated.
    thanks

    To add to this question: What is the best way to continue the animation until the end when the user exits the hit area instead of just jumping back to the Up state?
    Thanks
    Daniel

  • Displaying the results of an iterator in JTextfields.

    Hi people,
    I have got two methods which basically iterate through statements (forward and back).
    However I have a separate class which is basically the GUI for my program. I want the user to be able to click the next button and it iterates through the list and displays the element in the list in the JTextField.
    The problem I am having is that it will not display the element in the predefined fields, does anyone know how I can go about this? My code for my two methods is below:
    public void MusicNext()
               try
               if(titerator==null)
                   titerator = iList.listIterator();
               if(titerator.hasNext())
                   System.out.println(titerator.next());//Just prints out the iterator atm.
               else
                  titerator = null;
                  MusicNext();
               catch(ConcurrentModificationException ex)
                  titerator = iList.listIterator();
                  System.out.println("Iterator has been reset.");
              public Music MusicNext(String pTitle)
                Music tTitle = null;
             boolean found = false;
                Iterator it = iList.iterator();
                if(it.hasNext() && !found)
              tTitle = (Music) it.next();
              found = tTitle.getTitle().equalsIgnoreCase(pTitle);
                return tTitle;
            public void MusicPrevious()
               try
               if(titerator==null)
                   titerator = iList.listIterator();
               if(titerator.hasPrevious())
                   System.out.println(titerator.previous());//Just prints out the iterator atm.
               else
                  titerator = null;
               catch(ConcurrentModificationException ex)
                  titerator = iList.listIterator();
                  System.out.println("Iterator has been reset.");
               catch(NoSuchElementException ex)
                  //titerator = iList.listIterator();
                  System.out.println("No such element.");
         }I am pretty sure they shouldn't be void but should return an element, but I am really not sure what to return.
    Many Thanks,
    Rob.
    (Sorry I posted this before but I left out alot of detail).

    Don't get or instantiate the iterator in often-called methods.
    It should be get or instantiated as a class global field once and for all.
    Your ListIterator is good for such treatment becuase it can be
    freely scanned backward, while Iterator can't.

Maybe you are looking for

  • Out of memory prblem with threads

    class B implements Runnable If in class A I do while(true) B b = new B(); b.run() It can create 10000 instances of B, with no problem. Since b is in the scope of the while, the old instance is cleaned up by the garbage collector every loop. But if I

  • Using Flash in porlets

    Hi, I created one portlet and assigned to a remote server. the remote server pointing to jsp which displays the flash movie. i am able to play the flash movie if i access the jsp directly from the web server, but i am not able to see the flash movie

  • TS3274 NEW ipad "Not connected to Internet" ?  How do I resolve

    New ipad was connected , I think correctly but now when ipad is on it states internet  not connected  How do I eithe connect to wifi - or be able to contact support without connection?  AND some apps ie. Reminder and calendar appear to be in French a

  • I can't find my installer disc, where can I get a new one?

    I am trying to do a system restore to on my 2007 Macbook Pro so that I can pass it on to my wife. I have lost the install disc and was wondering how I could obtain another? Or is there another way to create an install disc from my laptop. If there is

  • Could not set values for dimension in disc R2

    We have a star schema with 11 dimensions. We have got the data in the analytic workspace. Now we are trying to create a cross-tab workbook using the wizard in Discoverer Plus R2. We were trying to have the slice of data based upon only Security Type