Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

after copying sample code HelloWorldSwing = Newbie

Status
Not open for further replies.

dekcool

Programmer
Oct 2, 2002
231
PH
hi good day!

after copying this code and saving as HelloWorldSwing.javac
c:\javac HelloWorldSwing.java
C:\java HelloWorldSwing

i got this error error dispatching:
java.lang.nosuchmethoderror
at HellowWorldSwing etc..........

any inputs will appreciate need this asap thanks in advance

Code:
import javax.swing.*;        

public class HelloWorldSwing {
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);

        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello World");
        frame.getContentPane().add(label);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

____________________________________________________
Invest your time in learning, Not just practicing.

DEK
 
you saved the file as "HelloWorldSwing.javac"?? it should be "HelloWorldSwing.java"

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
got this error error dispatching:
java.lang.nosuchmethoderror
at HellowWorldSwing etc..........

No! not 'etc.....', but the exact line-number, and the name of the missing/ misspelled method!

Aren't you missing some 'extends JFrame' or something like that?

seeking a job as java-programmer in Berlin:
 
guys thanks for the reply, here is the complete error

Code:
 Error:
Exeption occurred during event dispatching:
java.lang.nosuchmethoderror
    at HelloWorldSwing.createandshowgui(HelloWorldSwing.java:11)
    at HelloWorldSwing.access$000(HelloWorldSwing.java:3)
    at HelloWorldSwing$1.run(HelloWorldSwing.java:31)
    at java.awt.event.Invocationevent.dispatch(unknown source)
    at java.awt.eventQueue.dispatchEvent(unknown source)
    at java.awt.eventdispatchthread.pumpOneEeventForHierarchy(unknown source)
    at java.awt.eventdispatchthread.pumpEventsForhierarchy(unknown source)
    at java.awt.eventdispatchthread.pumpsEevent(unknown source)
    at java.awt.eventdispatchthread.run(unknown source)

____________________________________________________
Invest your time in learning, Not just practicing.

DEK
 
guys!

this code gave me an error, any idea why?
os: winXP

Code:
JFrame.setDefaultLookAndFeelDecorated(true);

____________________________________________________
Invest your time in learning, Not just practicing.

DEK
 
is your code and the stack trace a direct copy/paste?

because your code has a method
createAndShowGUI()

but your stack trace reports
HelloWorldSwing.createandshowgui

...which is accurate...you have no method createandshowgui()



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top