Join TSR now and get all your revision questions answeredSign up now

Java and Flickr - Help with Inheritance between Main Class and sub-class Watch

    • Thread Starter

    Dear all,

    I have been doing a small program which can help user search general photos by keywords and can retrieve most recent general uploads from Flickr.

    I created 4 classes:

    testUserInterface => to build all components for interface.

    testSearch => inherits interface from testUserInterface and build event action when user clicks on button start and button exit.

    PhotoFinder => get connection to Flickr.

    Link to view my code of PhotoFinder

    PhotoPanel => displays photos on this panel.

    Link to view my code of PhotoPanel

    When I select sub-menu "Search Photos" from class testUserInterface, a search panel is displayed with textfield and 2 buttons, start and exit.

    However, a problem occurs when I clicks start button (after entering a specific keyword).
    all photos which relates to the keyword is not shown.
    and I got problem with sub-menu instead in line 180.

    The errors are shown below:

    PHP Code:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastExceptionjavax.swing.JButton cannot be cast to javax.swing.JMenuItem at testUserInterface.actionPerformed(testUserInterfac javax.swing.AbstractButton.fireActionPerformed(Abs javax.swing.AbstractButton$Handler.actionPerformed ( javax.swing.DefaultButtonModel.fireActionPerformed ( javax.swing.DefaultButtonModel.setPressed(DefaultB javax.swing.plaf.basic.BasicButtonListener.mouseRe leased( java.awt.Component.processMouseEvent(Component.jav a:6505at javax.swing.JComponent.processMouseEvent(JComponen java.awt.Component.processEvent( 0at java.awt.Container.processEvent( 9at java.awt.Component.dispatchEventImpl(Component.jav a:4861at java.awt.Container.dispatchEventImpl(Container.jav a:2287at java.awt.Component.dispatchEvent( 87at java.awt.LightweightDispatcher.processMouseEvent(C java.awt.LightweightDispatcher.dispatchEvent(Conta java.awt.Container.dispatchEventImpl(Container.jav a:2273at java.awt.Window.dispatchEventImpl( at java.awt.Component.dispatchEvent( 87at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:723at java.awt.EventQueue.access$200( at java.awt.EventQueue$ java.awt.EventQueue$ Methodat$1.doIntersectionPri vilege($1.doIntersectionPri vilege( java.awt.EventQueue$ java.awt.EventQueue$ Methodat$1.doIntersectionPri vilege( java.awt.EventQueue.dispatchEvent(EventQueue.java693at java.awt.EventDispatchThread.pumpOneEventForFilter s( java.awt.EventDispatchThread.pumpEventsForFilter(E java.awt.EventDispatchThread.pumpEventsForHierarch y( java.awt.EventDispatchThread.pumpEvents(EventDispa java.awt.EventDispatchThread.pumpEvents(EventDispa
    Please help me out with the problem, it drives me crazy (TT)
Is GoT overrated?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Quick reply
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.