wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Got it working !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Got it working !!!" Watch "Got it working !!!" New topic
Author

Got it working !!!

Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
Hi
Thanks to Swami & Nathan with my problem regardint putting the background images in a button, I was able to make it work. All I did was to add an imagePanel directly to the button & add a mouseclicked event to the imagepanel to do the same job as that of the button's mouseclicked event. I used the SCALE_TO_FIT property of the imagepanel to scale the image inside the button & then added it as a component itself to the button.
Thanks again
Meghna
Swamy Vatti
Ranch Hand

Joined: May 02, 2001
Posts: 57
How about the other one... multi line button


Swamy
Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
Yeah, I'm still having some problems with multiline button. I'm using a delimiter "\n" and then wrapping the text to the next line. But, I'm setting the button's/ Imagepanel's layout to Borderlayout & then adding the labels to it. In Boxlayout, the problem is that the text is starting from the left most corner of the button, which does'nt look good since the text needs to be centered, alto' the alignment of the label is set to CENTER.
Any suggestions are welcome !
Thanks
Meghna
Swamy Vatti
Ranch Hand

Joined: May 02, 2001
Posts: 57
Did u try using
label.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label.setAlignmentY(JLabel.CENTER_ALIGNMENT);
when the layout is BoxLayout
Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
It kinda worked except for the fact that the text is placed at the topmost level of the button, but it is centered now. I'm tryint to work on that right now. Let's hope it works
Thanks
Meghna
 
wood burning stoves
 
subject: Got it working !!!
 
Similar Threads
Click a button to display an image. Trouble with add panel to a frame. Help !!
Component Please??
ToolTip not appearing
Applet with images overlayed and each image with a menu.
Problem Updating a JButton