1

I think the question title is quite confusing(didn't find much words for the problem), I will try to explain the problem below.

I want to include a feature similar to various chat applications. These applications have a feature to show the contacts of the user. Basically they show the profile picture(image) and online/offline status(image) and the name of the contact. When the user selects (by clicking) any of user the respective window for chat is opened (or the chat window is updated with this user information and chat history when only one chat window is used). Here is a snapshot of the element being clicked (or selected): enter image description here

So it is implemented(as I think) using a combination of image + image + Text. I suppose these must be using the radio buttons (or something similar). Now I want to do the same in Java but with java I can use only one image and text for the radio buttons. So I an wandering if there is any way to use more than one image as icon for one component in java swing. Or is there any other way to implement this feature.

me_digvijay
  • 5,374
  • 9
  • 46
  • 83
  • Create 2 components (or 3) and place them in a JPanel. – StanislavL Nov 16 '12 at 09:57
  • Consider using a [`JCheckBox`](http://docs.oracle.com/javase/6/docs/api/javax/swing/JCheckBox.html#JCheckBox%28javax.swing.Icon,%20boolean%29) instead. It only supports one icon, but the check-mark might serve as the 'online icon' (even better for people who are red/green color blind ;) ). – Andrew Thompson Nov 16 '12 at 09:57
  • How is this if you add a panel in front of all buttons and then map this extra image with button? – Freak Nov 16 '12 at 09:58
  • @StanislavL: So you mean the click events should be bind to the panel? Also the user should be allowed to click on any of the components and all of them should behave (as seen by the user) at the same time and in same manner. – me_digvijay Nov 16 '12 at 10:05
  • @AndrewThompson: I also considered this option, but this will put a limit of not using images and not very user friendly. – me_digvijay Nov 16 '12 at 10:06

1 Answers1

1
  • JRadioButton haven't Icon

  • there is drawIcon() only

  • JToggleButton is parent for JRadioButton

  • in this case then better could be to use set(Xxx)Icon() for JToggleButton

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Also consider implementing `Icon` as shown [here](http://stackoverflow.com/a/3072979/230513) and used [here](http://stackoverflow.com/a/13309587/230513). – trashgod Nov 16 '12 at 14:34