Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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 04-25-2008, 04:35 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
[SOLVED] Help Using ToolTipText Please
Hi, i am trying to use a tooltiptext for a JButton.

I am writing it in as

Code:
jbtCalculate.setToolTipText( "Calculates the total return of the bet") ;
and it is giving me back this error

Code:
StakePanel.java:26: <identifier> expected jbtCalculate.setToolTipText( "Calculates the total return of the bet") ; ^ StakePanel.java:26: illegal start of type jbtCalculate.setToolTipText( "Calculates the total return of the bet") ; ^ 2 errors
Any ideas what i am doing wrong?

BTW, i am using a Panel to do this in if that makes a difference
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-25-2008, 05:32 PM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
are you sure you imported the tooltexttip and I'm not sure if you can add one to a panel.
__________________
My IP address is 127.0.0.1
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-25-2008, 05:44 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Quote:
Originally Posted by Zosden View Post
are you sure you imported the tooltexttip and I'm not sure if you can add one to a panel.
These are what i have imported

Code:
import java.awt.event.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.text.*;
and as far as i'm aware, it's in the import javax.swing.*; one

EDIT

I have changed the code to the following:
Code:
jttCalculate = new JToolTip(); jttCalculate.setTipText("Calculates the total return of the bet"); jttCalcualte.setComponent(jbtCalculate);
Still not working though

Getting these errors

Code:
StakePanel.java:22: <identifier> expected jttCalculate= new JToolTip(); ^ StakePanel.java:23: <identifier> expected jttCalculate.setTipText("Calculates the total return of the bet"); ^ StakePanel.java:23: illegal start of type jttCalculate.setTipText("Calculates the total return of the bet"); ^ StakePanel.java:24: <identifier> expected jttCalcualte.setComponent(jbtCalculate); ^ StakePanel.java:24: <identifier> expected jttCalcualte.setComponent(jbtCalculate); ^ 5 errors

Last edited by Renegade85 : 04-25-2008 at 05:53 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-26-2008, 04:34 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
No need to use JToolTip...

It's already inherited from JComponent......

I think there is no wrong about setting the tooltiptext....
I don't know.. bec you didn't show us your complete code....

Here is an example,

Code:
import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; public class test extends JFrame{ public test(){ JButton jb = new JButton("Click here"); jb.setToolTipText( "Would you like to click me?"); add(new JPanel().add(jb)); setBounds(100,100,100,100); setDefaultCloseOperation(3); } public static void main(String args[]){ new test().setVisible(true); } }
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 04-26-2008 at 04:37 AM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-26-2008, 10:20 AM
Zosden's Avatar
Senior Member
 
Join Date: Apr 2008
Posts: 386
Zosden is on a distinguished road
The way I used tooltip before is just add it to the component I want with the specified string. I never declared and created a tooltip object
__________________
My IP address is 127.0.0.1
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-28-2008, 12:25 PM
Member
 
Join Date: Dec 2007
Posts: 25
Renegade85 is on a distinguished road
Ok, thanks for the help guys Got it working
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



All times are GMT +3. The time now is 12:00 PM.


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