• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I get Frame?

 
Ron Aronica
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing an <code>AbstractTableModel</code> class with a <code>getColumnClass</code> method. The method calls another method that can throw an exception. I want the <code>getColumnClass</code> to display a dialog and exit the application in response to the exception. Is this a reasonable course of action? If so, how do I get the frame to which the associated <code>JTable</code> belongs so that I can display the dialog?
Thanks,
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it might be reasonable, depending how severe the error is. Exiting the application should be a last resort. If there's anything you can do to recover from the error, that is a better way to go.
To find the frame or dialog a component is in: JComponent.getTopLevelAncestor() will do the job.
 
Ron Aronica
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately the JComponent method will not work. AbstractDataModel only derives from Object, not from JComponent. Do you have any other suggestions?
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!