Hi Pavan
Do in some initialization code region (in the constructor on in an
initialization method called by the constructor), something like.:
myJLabel.addMouseListener(new java.awt.event.MouseAdapter(){
public void mouseEntered( java.awt.event.MouseEvent e ){
myLabel.setFont( new java.awt.Font( "Dialog", 1, 12 ));
}
public void mouseExited( java.awt.event.MouseEvent e ){
myLabel.setFont( new java.awt.Font( "Dialog", 0, 12 ));
}
}
);
Above:
-- "Dialog" is the name of the font
-- 1 or 0 means "Bold" or "not Bold"
-- 12 is the font size
Of course, you can do better, for e.g. by creating the two Font objects
in the beginning and then passing the right Font instead of creating it
each time, and so on (for the optimizations).
A good way to see how to do this kind of thinks is:
-- Use NetBeans to create labels with and without Bold fonts (property
"font") - the Swing WYSIWYG editor is very good,
-- then look at the way NetBeans handle it in the method
"initComponents()" (you'll have to "unfold" the section - the code is
normally hidden),
-- then look at the Java documentation for the description of the used
classes and methods.
Hope it helps
Mihai
pavan kumar a écrit :
Implement MouseListener and write the code for boldening text in
mouseEntered method and undone text in mouseExited method.
On Wed, Jun 23, 2010 at 4:54 PM, elvis sarfo <[email protected]
<mailto:[email protected]>> wrote:
hi folks,
i have a JLabel gui and what i want to do is that when i place the
mouse on the label, the text should be underlined and the font
boldened and when i remove the mouse from it the text should be as
it was before(that is not underlined and plain). I have been
trying everything out but can't do it. Please can somebody help me
out? Appreciate your attention
--
To post to this group, send email to
[email protected]
<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]
<mailto:javaprogrammingwithpassion%[email protected]>
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
Thanks,
Pawan.
While one person hesitates because he feels inferior, another is busy
making mistakes and becoming superior.
Henry C. Link
--
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en