Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2008, 09:10 AM
Member
 
Join Date: Jan 2008
Posts: 78
Preethi is on a distinguished road
Tooltip
I'm writing a program using swing applet.To the container i add the scrollPanle,to the i added panel above which i drawn my drawings...Now i want to add tooltip,when the mouse point goes over the drawing by showing its coordinates..Now i want to know how to add tooltip to the drawing?
Please help me....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-11-2008, 09:22 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
You mean on the panel?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-11-2008, 10:51 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
If you JPanel is mainPanel try it as follows.

Code:
mainPanel.setToolTipText("Just for testings those text");
at the appropriate place of your code. Better to do it panel implementation.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-11-2008, 12:13 PM
Member
 
Join Date: Jan 2008
Posts: 78
Preethi is on a distinguished road
I tried in the way you said,but its not working out for me...Its not getting displayed....

Quote:
public class NewClass
{
public void init()
{
Container cont = getContentPane();
cont.setLayout(new BorderLayout());
setPreferredSize(new Dimension(300, 300));
JScrollPane scroll = new JScrollPane();
getContentPane().add(scroll, BorderLayout.CENTER);

}
private class Imagepanel extends JPanel implements MouseListener,MouseMotionListener
{

panel();
addMouseMotionListener(this);
addMouseListener(this);
}
public void panel()
{
StartDate obj = new StartDate();
int w = obj.diff();
int dimension = 0;
int size = xmlreadingObj.getres_list().size();
int height = 100 + size * 28;
width = w;
System.out.println("width"+width);

setPreferredSize(new Dimension(width, height));
setBorder(BorderFactory.createLineBorder(Color.BLA CK, border));
l = new JLabel("HAI");
add(l,BorderLayout.EAST);
l.setVisible(true);
l.setLocation(100,50);
}

protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawRect(100,200,15,20);
g2.drawRect(200,200,15,20);

}
public void mousePressed(MouseEvent e)
{
Point p = e.getPoint();
x_Pos = e.getX();
y_Pos = e.getY();

for(int j = 0; j < rects.length; j++)
{
if(rects[j].contains(p))
{
selectedindex = j;
selectedRect = rects[j];
dragging = true;
break;
}
}
}
public void mouseMoved(MouseEvent e)
{
Imagepanel image = new Imagepanel();
l = new JLabel();
Point p = e.getPoint();
if(rects[selectedindex].contains(p))
{
image.add(l);
image.setToolTipText("Just to test");

}
else
{
candisplay = false;
}
}
}
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-11-2008, 12:27 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
What is your Imagepanel do. Is it return a panel?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-11-2008, 12:37 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
See how this simple widow works.

Code:
import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; /** * * @author Eranga Tennakoon */ public class ToolTipDemo { JPanel pan = new JPanel(); /** * @param args the command line arguments */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new ToolTipDemo().createAndShowGUI(); } }); } private void createAndShowGUI() { System.out.println("Created GUI on EDT? "+ SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("ToolTip Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pan.setToolTipText("This is a tool tip"); pan.setPreferredSize(new Dimension(250, 250)); f.add(pan); f.pack(); f.setVisible(true); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem to ToolTip in Java 3d roshithmca AWT / Swing 1 02-05-2008 04:46 AM
How to create ToolTip in Java 3d roshithmca AWT / Swing 0 02-04-2008 07:57 AM


All times are GMT +3. The time now is 06:09 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org