• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to understand how to remove exception raised here.

 
Yaki Kumar
Greenhorn
Posts: 12
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the code for my ChatManager Class.


I wrote a FChatManager - for Facebook Chat as below:


Further I have ChatBuddy class that represents User/Buddy available for chat ... I get it when I receive Presence packet .


What I wanted to do is add/remove users, along with their images (which I could get from vCard) from a List in the ChatManager as and when they become available/unavailable. The problem is, I keep getting following...


Class of value: class javax.swing.plaf.basic.BasicPanelUI
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.plaf.basic.BasicPanelUI cannot be cast to ui.ChatBuddy
at ui.ChatManager$BuddyRenderer.getListCellRendererComponent(ChatManager.java:84)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1344)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1294)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:561)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
at java.awt.Container.layout(Container.java:1421)
at java.awt.Container.doLayout(Container.java:1410)
at java.awt.Container.validateTree(Container.java:1507)
at java.awt.Container.validate(Container.java:1480)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122).......


What I don't get is I am adding a ChatBuddy at Line Number 60 in FChatManager to the List.. via ChatManager's addBuddy(ChatBuddy buddy) at Line No. 60 in ChatManager but javax.swing.plaf.basic.BasicPanelUI is what it gets... which is all the reason I think its failing. How could I get rid of this?? I don't have in depth knowledge of Java
Please I need help... after so long I have zeroed to using JList to display users online and also wrote a Simple Program and adding some custom Object to List.. there it said that the object received was the one that I had added.
Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wild guess



maybe it should be
chatListModel.addElement(buddy);
 
Yaki Kumar
Greenhorn
Posts: 12
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Dunn. It was a silly mistake.
Just one more thing? Do you think, my design is kind of Okay?? Like doing most of the thing is an abstract class (Chat Manager)... and doing only Specific Things .. like related to Facebook in FChatManager which extends ChatManager??
Thanks a LOT.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic