Please Help trouble with error Java 34

I'm working on a basic program that uses JButton and JFrame for display/activity, I have been able to get the rest of the program running but I get this error when trying to Register a button event listener.
.java:34: non-static variable this cannot be referenced from a static context
          createAction = new ButtonHandler();
^
The code I used to create this Button is
     JButton create;
          ButtonHandler createAction;
          create = new JButton("Create");
          createAction = new ButtonHandler();
          create.addActionListener(createAction);
Does anyone know why I am getting this error? I tried removing Static from my class main declaration but then the program terminates with this error
java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
Edited by: Grudairian on Oct 25, 2007 3:39 PM

Grudairian wrote:
I'm working on a basic program that uses JButton and JFrame for display/activity, I have been able to get the rest of the program running but I get this error when trying to Register a button event listener.
.java:34: non-static variable this cannot be referenced from a static context
          createAction = new ButtonHandler();
^
The code I used to create this Button is
     JButton create;
          ButtonHandler createAction;
          create = new JButton("Create");
          createAction = new ButtonHandler();
          create.addActionListener(createAction);
Does anyone know why I am getting this error? I tried removing Static from my class main declaration but then the program terminates with this error
java.lang.NoSuchMethodError: main
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
Edited by: Grudairian on Oct 25, 2007 3:39 PMWhat you are trying to do is so overwhelmingly wrong that there is absolutely no way you have any idea what you are doing. You most certainly should not be trying to build GUI applications; have you gone through the Sun tutorial? Do you understand what the static (notice that it is all lowercase, because java is a case sensitive language) keyword means? How about the "this" keyword? Do you know what an instance is? Do you know the difference between a class and an object? If the answers to ANY of those questions is "no", then you need to go through the basic java tutorial:
http://java.sun.com/docs/books/tutorial/

Similar Messages

  • Please help me with these java puzzle ?

    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    Please help me with these java puzzle ?
    Dear all,
    My friend send me typical java puzzle about java.util.ArrayList
    which is getting messy. Please help me out. It's not a homework.
    import java.util.*;
    public class MyInt ______ ________ {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    ________ int ___________ {
    MyInt i2 = (MyInt)o;
    return ________;
    }Hints , fill the underlines with below :
    implements
    extends
    Sortable
    Object
    Comparable
    protected
    public
    i = i2.i
    i
    i2.i=i
    compare(MyInt o, MyInt i2)
    compare(Object o, Object i2)
    sort(Object o) sort(MyInt o)
    compareTo(MyInt o)
    compareTo(Object o)

    Dear all,
    My friend send me typical java puzzle aboutNotwithstanding your pathetic protestations typicial
    of all your posts this is NOT a typical java "puzzle"
    but is indeed a typical homework puzzle.
    And it's damn easy if you spent 30 minutes with a
    tutorial.
    DO YOUR OWN HOMEWORK!
    Hey i did it.
    import java.util.*;
    public class MyInt implements Comparable {
    public static void main(String[] args) {
    ArrayList<MyInt> list = new ArrayList<MyInt>();
    list.add(new MyInt(2));
    list.add(new MyInt(1));
    Collections.sort(list);
    System.out.println(list);
    private int i;
    public MyInt(int i) { this.i = i; }
    public String toString() { return Integer.toString(i); }
    public int compareTo(Object o){
    MyInt i2 = (MyInt)o;
    return i;
    }E:\>javac MyInt.java
    Note: MyInt.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    E:\>java MyInt
    [1, 2]

  • Please Help, trouble with j2sdk 1.4.2

    Hello anyone,
    Im only a rookie with java so,
    can some one please help me on why Java 2 SDK 1.4.2 cant preview my class files
    i have made very simple programs and compiled them by javac and after i type java (file name).class its come up with an error msg.
    the code is...
    import java.util.*;
    public class ExampleProgram
    public static void main(String[] args)
    System.out.println("Testing Java");

    Hello Mike and BBQ Frito
    thanx for all your help it works now
    all i had to do was type SET CLASSPATH and then type the file without .class
    thanx again bye
    andy

  • Please HELP me with installation - java.lang.noclassdeffounderror:

    Please Help! For school we need to install JAVA. I installed JDK 5.0 and id did not work. I got exception in thread "main" java.lang.noclassdeffounderror: hello. I was using Texpad to write, compile, and run it. In short I deleted all JAVA 5.0 using My Computer program removal. I installed JAVA 1.4..2_10 and I am still getting that same error. I want the JAVA 1.4..2_10 to be installed and not JAVA.5.0.
    My System Variable CLASSPATH still shows C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip. My System Variable PATH has nothing as far as JAVA in it. MY PATHEXT has JS and JSE amoung other things in it. My System Variable QTJAVA still has Files\Java\jre1.5.0_03\lib\ext\QTJava.zip in it.
    Please tell me step-by-step how I can fix this. I never updated these variables before. What do I need to type and where? What do I need to get rid of or change?
    PLEASE HELP!
    Thanks,
    Jim

    I left my System variable classpath --> C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip I left my QT JAVA --> C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip I added Path --> ;C:\j2sdk1.4.2_10\bin and then restarted my computer. I added hello file in C:\j2sdk1.4.2_10\bin and tried to compile it under a new name and it would not compile. it gave me the error below. I was able to compile other java program in my other folder in a different directory. I am still getting the same error messages/ Anything else I should try? IS there anyplace or person I can call who would come and fix this? Something is wrong. This should not be giving me this much trouble. All The Java directions on other websites tell me to do different things. I am so confused... please help.
    I get this during the compilenow:
    javac: invalid flag: C:\j2sdk1.4.2_10\bin\helloa.txt
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are used
    -classpath <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -help Print a synopsis of standard options
    Tool completed with exit code 2
    Jim
    If you can fix this I will give you 14 points. I hope it is enough. I just want this to work for school.

  • Can someone please help me with a java assignment

    Hey all,
    I have a favor to ask I have a program that I need for my java class, I have the just of it but I can't figure out the rest, can anybody please help me here is the directions:
    Let's revisit fibonacci numbers, looking at it as a process involving iteration and arrays. Create an array fib[] of 101 elements. Make fib[0] = 0 and fib[1] = 1. Then, in an iterative process going from 2 to 100, compute fib[k]. These numbers get quite large; make it an array of double.
    Then, let the user select a number (such as 7) and have the application display the corresponding finbonacci number (in this case 13). Do this as often as the user wants. If a number larger than 100 is provided, display an error message, but don't terminate the program.
    Here is what I have so far: Please add on and feel free to return to me please, thank you:
    // This is an application that transforms numbers into their Fibonacci number
    import javax.swing.*;
    public class Fibonacci {
         public static void main( String args[] ){
              int k; //simple counter
              int numSize; // how many numbers were entered
              int theNum; // the number entered by the user
              String response; //response of the user
              // define the array
              double fib[] = new double[ 101 ];
              // read in the numbers into an array
              k = 0;
              response = JOptionPane.showInputDialog( "Enter the first number" );
              theNum = Integer.parseInt( response );
              while (theNum > 0){
                   if (theNum > 100)
              k++;
              fib [ 1 ] = 1;
              fib [ 2 ] = 1;
              response = JOptionPane.showInputDialog( "Enter the next number, negative to end" );
              theNum = Integer.parseInt( response );
         } // end while
         numSize = k;
    // terminate
    System.exit( 0 );
    }// end main
    } //end class Fibonacci

    Try this program..Hope it helps
    import javax.swing.*;
    public class Fibonacci
         static double fib[];
         public Fibonacci()
              fib = new double[ 101 ];
              fib[0] = 0;
              fib[1] = 1;
              for(int i = 2; i < fib.length; i++)
                   fib[i] = fib[i -1] + fib[i - 2];
         public static void main( String args[] )
              boolean end = true;
              String response = "";
              int theNum = 0;
              new Fibonacci();
              while(end)
                   response = JOptionPane.showInputDialog( "Enter the number. 999 to end" );
                   try
                        theNum = Integer.parseInt( response );
                        if(theNum == 999)
                             end = false;
                        else if(theNum <101)
                             String Message = "The Fibonacci number at "+ theNum + " is : "+ fib[theNum - 1];
                             JOptionPane.showMessageDialog(null, Message, "Fibonacci Number", JOptionPane.INFORMATION_MESSAGE);
                        else
                             JOptionPane.showMessageDialog(null, "Input should be less than 100", "Error", JOptionPane.ERROR_MESSAGE);
                   catch(NumberFormatException ex)
                        JOptionPane.showMessageDialog(null, "Enter Numeric values", "Error", JOptionPane.ERROR_MESSAGE);
              System.exit(0);
         }// end main
    } //end class FibonacciVish

  • Can Someone please help me with ERROR 4251

    I have tried everything! even slowing down the burn speed.
    Can someone please help with error 4251 when burning.
    I have my diagnostics report done as well.
    Thank you to anyone who can help.

    I did a quick google search for "iTunes error 4251" and this was the first result.
    http://forums.techarena.in/motherboard-processor-ram/1215316.htm
    The last post in that forum said a few things.
    1.Restart computer
    2.Disable anti-virus/security programs
    3.Update hardware and software drivers.(I'm guessing mainly the cd-rom drive drivers)
    Try those things and see if it is still a problem.
    ~Bill L.

  • Please Help: Trouble with nested CASE statement and comparing dates

    Please tell me why the query below is always returning the bold null even when the start_date of OLD is greater than or equal to the start_date of NEW.
    What I want to do is get the difference of the start_dates of two statuses ( Start_date of OLD - Start_date of NEW) if
    1. end_date of NEW is not null
    2. start_date of OLD is greater than start_date of NEW
    else return null.
    select id,
    case when max(end_date) keep (dense_rank last order by decode(request_wflow_status,'New',1,0),start_date) is null then
    null
    else
              case when max(decode(status,'OLD',start_date,null)) > max(decode(status,'NEW',start_date,null))
              then max(decode(status,'OLD',start_date,null)) - max(decode(status,'NEW',start_date,null))
    else
    null
    end
    end result
    from cc_request_status where id =1
    group by id;

    Avinash,
    Thank you for your help.. Here is a more description of my problem..
    Here is a sample of data I have for a table with four columns (id,status,start_date,end_date)
    What I need to do is to get difference of the start dates of the maximum available dates, if data is valid. The pseducode is as follows:
    IF end_date of New status is null
    THEN return null
    ELSE
    IF start_date of old >= start_date of new
    THEN return (start_date of old - start_date of new)
    ELSE return null
    I used the following query but always return the bold null
    select id,
    (case when max(end_date) keep (dense_rank last order by decode(status,'new',1,0),start_date) is null then
    null
    else
              (case when max(decode(status,'old',start_date,null)) >=
              max(decode(status,'new',start_date,null))
              then max(decode(status,'old',start_date,null)) - max(decode(status,'new',start_date,null))
    else
    null
    end)
    end) result
    from tbl where id =1
    Based on the below sample, I expected to get the following result; 14-Mar-07 - 16-Feb-07 which is the difference of the maximum start_dates of the two statuses. However the query is not working.. Please help me.. Thank you..
    Id    Status    start_date      end_date
    1     new      03-Feb-07      07-Feb-07
    1     new      16-Feb-07      21-Feb-07
    1     old      '10-Mar-07      12-Mar-07
    1     old      '14-Mar-07      16-Mar-07

  • Can someone please help me with error 29

    help with error 29 on my 3gs

    Hey Li0666,
    I see that you are experiencing an issue with your iOS device and it has been recognized with an error code. Here is an article for you that will help you address this issue and identify the error code:
    Check for hardware issues
    Related errors: 1, 3, 11, 12, 13, 14, 16, 20, 21, 23, 26, 27, 28, 29, 34, 35, 36, 37, 40, 1002, 1004, 1011, 1012, 1014, 1667, or 1669.
    These errors mean that your device or computer might have a hardware issue that stops the update or restore from completing.
    Check that your security software and settings aren't blocking your device from communicating with the Apple update server.
    Then try to restore your iOS device two more times while connected with a cable, computer, and network you know are good.
    Make sure that your security software and settings are allowing communication between your device and update servers.
    If you still see the error message when you update or restore, contact Apple support.
    Get help with iOS update and restore errors - Apple Support
    https://support.apple.com/en-us/TS3694
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • Please please help trouble with exported quality

    please please help me> i have been searching the net for over 3 hrs for a solution and whatever I have found has been a little too technical for me . I am uploading video to i movie from a disk. the file types on the disk are mp4. I am then editing the clips on iMovie '09 when I go to export the movie I am chosing to export movie as a "large" 960x540
    .mov file. The quality ***...it is blurry and grainy and unusable. Someone in another forum told me to run the mp4 movie in quicktime and tell them what movie inspector says about the clip. Movie inspector says:
    Formatt: Apple MPEG4 Decompressor, 640 × 480, Millions
    FPS: 29.97
    Playing FPS: 30
    Data size 129 MB
    Data Rate: 1504.39 kbits/s
    Size 640 x 480
    I am dying over here any help please? and thank you all so much

    once I share to the media browser where does it go? cant find it.
    It's "hidden" in your user folder Movies>iMovie Projects. Right-click (Control-click) on the name of your Project and select "Show Package Contents". In the folder named Movies you will see your exported file. It could be either a .m4v or .mov file, or possibly another type, depending on whether standard definition or high definition and the size option chosen when exported. If you are producing a DVD, you drag the file from iDVD's Media-Movies pane onto the Theme background.
    Also, when sharing to the media browser I can only save it as "medium" quality...the other choices arent available?
    Then AppleMan's earlier advice will be correct (as always) - he recommended using the Medium setting based on your QuickTime details. It appears that your original MP4 video has an aspect ratio of 4:3, unless your Project settings are incorrect. You set the dimensions (standard 4:3, widescreen 16:9 or iPhone 3:2) of the project in File>Project Properties then selecting the General tab.
    In iMovie '09, I've mainly worked with AVCHD video which produces .MTS files that are converted to AIC (Apple Intermediate Codec) on import. This is high definition footage which iMovie can import as 1920 x 1080 or 960 x 540 (both widescreen 16:9). Hence, on export I can share at Large (960 x 540) or HD (1280 x 720). I'm not sure why you are only seeing a Medium option - could be due to the aspect ratio or maybe it's standard definition in MP4 format (just guessing!). If other options are greyed out, have you tried ticking the boxes - that activates each option for me.
    John

  • PLEASE  HELP ME..ERROR: JAVA CORRUPT ..

    Hello! I bought a disk called the UnInstaller by McAfee. I had some items I wanted removed off of my computer, but really had no idead exactly what I was doing. I told the disk to make the most availible space on my computer. Well, needless to say, I somehow delelted something crucial to the Java program. I have no idea of how to fix this, as I have already tried reinstalling the browser, and it still didn't help. When I try to go to Pogo.com to play the games, since I deleted over 10,000 files, I have been receiving this message that I have pasted below:
    The following error has occurred:
    Java Corrupted or Misinstalled
    Explanation:
    This error occurs when your Java software has been either misinstalled on your browser or if Java software has been corrupted in some way. Some of the symptoms include a large number of "exception errors", applets not showing up (or showing up as a blank or gray frame), and other crash problems.
    How to Fix the Problem:
    The best way to solve the problem is to upgrade to a newer version of the browser you use. This will come with the latest versions of the Java software so you'll be able to run our Classic Games properly. (You should uninstall your current version before you begin the upgrade in order to start with a clean setup.) If you're already using the latest version of your browser and are experiencing this problem, it's still best if you uninstall your browser and then reinstall to begin anew.
    I have done as the error message stated to do in order to correct this, but I am not able to play any online games now because of this stupid mistake I made. If anyone can help me, it would be so helpful and greatly appreciated! Thank you for your time. Have a great day :-)

    Hello! I bought a disk called the UnInstaller by
    McAfee. I had some items I wanted removed off of my
    computer, but really had no idead exactly what I was
    doing. I told the disk to make the most availible
    space on my computer. Well, needless to say, I
    somehow delelted something crucial to the Java
    program. I have no idea of how to fix this, as I have
    already tried reinstalling the browser, and it still
    didn't help. When I try to go to Pogo.com to play the
    games, since I deleted over 10,000 files, I have been
    receiving this message that I have pasted below:
    The following error has occurred:
    Java Corrupted or Misinstalled
    Explanation:
    This error occurs when your Java software has been
    either misinstalled on your browser or if Java
    software has been corrupted in some way. Some of the
    symptoms include a large number of "exception errors",
    applets not showing up (or showing up as a blank or
    gray frame), and other crash problems.
    How to Fix the Problem:
    The best way to solve the problem is to upgrade to a
    newer version of the browser you use. This will come
    with the latest versions of the Java software so
    you'll be able to run our Classic Games properly. (You
    should uninstall your current version before you begin
    the upgrade in order to start with a clean setup.) If
    you're already using the latest version of your
    browser and are experiencing this problem, it's still
    best if you uninstall your browser and then reinstall
    to begin anew.
    I have done as the error message stated to do in order
    to correct this, but I am not able to play any online
    games now because of this stupid mistake I made. If
    anyone can help me, it would be so helpful and greatly
    appreciated! Thank you for your time. Have a great
    day :-)

  • Please help me with JACOB: Java-Com Bridge

    While experimenting with Jacob 1.13, I am not even able to run the sample code that comes with the source package. I get an error as below:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: createInstanceCan you help?
    And, is there another way to access MS Word? Basically what I want to do is search and find some text in Word documents and apply some styles to it.
    Thanks in advance for your advice!

    I am guessing that underneath the code you see, it uses the MS Word DLLs to emulate MS Word. So if you don't actually have Word installed in your machine you won't be able to do this.

  • Please help me with two Java problems

    Hello,
    I have 2 Java problems to work on and wondered if someone can help please?
    1. I've created an array, but I have to now create a text file and write a program to read the array from the file. I have no idea where to start the program!
    2.public class SumExample1 {
    /* To determine if a number lies between 1 and 1000
    * @param args the command line arguments
    public static void main(String[] args) {
    int num;
    System.out.print("Enter a number: ");
    num = TextIO.getInt();
    if ((num >=1) && (num<=1000))
    System.out.println("OK");
    else
    System.out.println ("Not OK");
    Ive used a GUI to create some fields and buttons to press. How can I make it perform this little program?
    Many thanks,
    K

    I recommend you read the tutorials on basic (file) IO and Swing (and Event Listeners if you want to make your GUI alive). Perhaps have a look at the Scanner class and BufferedInputStream. That should give you enough to start and write the program yourself. Try working in the command prompt first, should be easier, then once the logic works wrap it in a Swing GUI.
    You can find the tutorials here:
    http://download.oracle.com/javase/tutorial/
    Swing:
    http://download.oracle.com/javase/tutorial/uiswing/index.html
    Basic IO:
    http://download.oracle.com/javase/tutorial/essential/io/index.html
    Hope this helps.
    PR

  • I'm really frustraded - Please help - Trouble with printing

    Hello guys, Im programing a software for a parking lot in java. I need to print tickets with an EPSON U220 printer. When I print, the margins of the paper are all messed up. It seems I can only print from the half of the paper to the left. What can it be? also, when I print from notepad the same happens, half of the paper is blank and only the other half prints.
    How could I solve this problem?
    Where could I start reading?
    Thanks ALOT for your time!
    Best regards
    Michel
    Edited by: mbehlok on Oct 23, 2009 8:02 PM

    mbehlok wrote:
    also, when I print from notepad the same happensSounds like the issue is completely unrelated to Java. Maybe a printer driver bug. Check/contact Epson support.

  • Please help me with an error 1418...

    OK I have iPod mini 4GB and I have the latest iTunes installed 7.02 or something I don't know anymore.
    Anyway a sad iPod icon displayed on my screen a few days ago and I managed to restart it and to put it in a disk mode and then iTunes finally recognized iPod and I clicked on Restore and then Restore and Updated and after a few seconds during the restore process it says:
    An iPod 'iPod' couldn't be resoterd. An unknown error occurred (1418).
    I am desperate and i don't know what to do.
    I read almost everything about this but nothing helped.
    Please help me with any kind of solution...

    I did a Support Search for that error number and this is what I got. I hope one of these links helps:
    http://docs.info.apple.com/article.html?artnum=304508
    http://docs.info.apple.com/article.html?artnum=304996

  • I cannot install itunes on my windown 7 laptop.  Error says "computer not modified".  Please help me with this problem.

    I cannot install Itunes and Icloud on my Sony Vaio Laptop - Window 7.  Error says " computer/system not modified".  Please help me with this problem. 

    Hello there, jag123059.
    The following Knowledge Base article offers up some great steps to follow for resolving issues with installing iTunes:
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/ht1926
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

Maybe you are looking for

  • DAX - Grouping by 2 different fields in 1

    Hi, Imagine a table that has persons. Persons have a set of attributes like Father and Mother profession. In each of the fields, the contents are on the same context, you can have a person that has a father or mother that is a doctor, engineer or tea

  • Using iPhoto after photo transfer

    As a novice to Mac, I have recently learned how to transfer photos into iPhoto from my mobile. However, once imported my photographs are smaller than normal screen size. Can they be edited to full screen size. I have tried increasing the slider to ma

  • Ugly Terminal Font

    I have an old application that has a text indicator requiring a non-proportionally spaced font. Years ago, it looked great with 11pt terminal font. I recently tried to update that application and noticed that the text display has became very ugly, bl

  • HELP itunes won't update ALL tracks

    I imported tracks onto itunes & they were skipping so i re-imported & replaced the existing files. now the tracks in itunes are perfect, except i can not get them to upload onto my ipod as no matter what preferences i select it will only ever upload

  • How can I make podcasts play continuously. And Why do I have to sign in to itunes twice every time I open it?

    How can I make podcasts play continuously. And Why do I have to sign in to itunes twice every time I open it?