3 Replies - 834 Views - Last Post: 15 October 2012 - 10:31 AM Rate Topic: -----

#1 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

putting tooltip on iconified internal frame

Posted 04 October 2012 - 12:58 PM

Does any one have know how to add the toolTip text to an JInternalFrame so it will
show when the iconified frame is mousedin or when the iconified frame is selected?
I have a InternalFrameListener on all the frames .

I tried the InternalFrameListener and the propertyChangeListener


 
       public static class InternalFrameListener extends InternalFrameAdapter implements Serializable {

       

       public void internalFrameIconified(InternalFrameEvent e) {
            displayMessage("Internal frame iconified", e);

            final String text=e.getInternalFrame().getTitle();
            e.getInternalFrame().setToolTipText(text);
            final JInternalFrame source=e.getInternalFrame();
           e.getInternalFrame().addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseEntered(MouseEvent e) {
                            //super.mouseEntered(e);
                            source.setToolTipText(text);
                        }
           });
        }


        }
    }






 private static class InternalFrameClicked {

        
        private static JPopupMenu popupMenu;

        private InternalFrameClicked(MouseEvent e, String toolTipText) {


           

// code is not working 
            if (e.getButton() != MouseEvent.BUTTON1 && e.getClickCount() == 1) {   // if is right-click
                System.out.println(C + M + AND + " var :  if (e.getButton() != MouseEvent.BUTTON1 && e.getClickCount() == 1) {  : \n");

                // create popup with Close menuitem

                popupMenu = new JPopupMenu();
                popupMenu.add(toolTipText);
                // display popup near location of mouse click
                popupMenu.show(e.getComponent(), e.getX(), e.getY() - 10);

            }
        }
    }





if (propertyName.equals(JInternalFrame.IS_ICON_PROPERTY)) {

                final JInternalFrame source = (JInternalFrame) propertyChangeEvent.getSource();
                final String s = source.getTitle();
                System.out.println(C + M + AND + s + ":  final String s =  source.getTitle();: \n");

                
                    source.addMouseListener(new java.awt.event.MouseAdapter() {

                        @Override
                        public void mouseEntered(MouseEvent e) {
                            //super.mouseEntered(e);
                            source.setToolTipText(s);
                        }
                    });

                }



Is This A Good Question/Topic? 0
  • +

Replies To: putting tooltip on iconified internal frame

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,466
  • Joined: 27-December 08

Re: putting tooltip on iconified internal frame

Posted 04 October 2012 - 01:14 PM

Please don't post help questions in the Advanced Discussion forum. Moved to Java.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: putting tooltip on iconified internal frame

Posted 04 October 2012 - 07:30 PM

ToolTip is a Java feature and can be used when a Java is up and running

When your application is iconified, it is the OS which takes the relay to display the icon, Java is not involved at all... so the ToolTip concept ....

Somewhere else in this forum, years ago, I have managed to find a way to make the iconified icon to blink but this is another story :)
Was This Post Helpful? 0
  • +
  • -

#4 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

Re: putting tooltip on iconified internal frame

Posted 15 October 2012 - 10:31 AM

I needed the JInternalFrame to show the tooltip. Thanks for the try. I found the .getDesktopIcon(). and put it in a
"for" loop to re apply all the titles to tooltips when any frame is iconified.



public static class InternalFrameListener extends InternalFrameAdapter implements Serializable {

       

       public void internalFrameIconified(InternalFrameEvent e) {
            displayMessage("Internal frame iconified", e);

            final String text=e.getInternalFrame().getTitle();
            e.getInternalFrame().setToolTipText(text);
            final JInternalFrame source=e.getInternalFrame();
           e.getInternalFrame().addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseEntered(MouseEvent e) {
                            //super.mouseEntered(e);
                            source.setToolTipText(text);
                        }
           });
        }


        }
    }



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1