Results 1 to 6 of 6
- 04-25-2008, 02:35 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 25
- Rep Power
- 0
[SOLVED] Help Using ToolTipText Please
Hi, i am trying to use a tooltiptext for a JButton.
I am writing it in as
and it is giving me back this errorJava Code:jbtCalculate.setToolTipText( "Calculates the total return of the bet") ;
Any ideas what i am doing wrong?Java 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
BTW, i am using a Panel to do this in if that makes a difference :confused:
- 04-25-2008, 03:32 PM #2
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
- 04-25-2008, 03:44 PM #3
Member
- Join Date
- Nov 2007
- Posts
- 25
- Rep Power
- 0
These are what i have imported
and as far as i'm aware, it's in the import javax.swing.*; oneJava Code:import java.awt.event.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.text.*;
EDIT
I have changed the code to the following:
Still not working though :(Java Code:jttCalculate = new JToolTip(); jttCalculate.setTipText("Calculates the total return of the bet"); jttCalcualte.setComponent(jbtCalculate);
Getting these errors
Java 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 errorsLast edited by Renegade85; 04-25-2008 at 03:53 PM.
- 04-26-2008, 02:34 AM #4
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,
Java 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); } }Last edited by sukatoa; 04-26-2008 at 02:37 AM.
freedom exists in the world of ideas
- 04-26-2008, 08:20 AM #5
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
- 04-28-2008, 10:25 AM #6
Member
- Join Date
- Nov 2007
- Posts
- 25
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks