wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Calling Classes of JFrame errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Calling Classes of JFrame errors" Watch "Calling Classes of JFrame errors" New topic
Author

Calling Classes of JFrame errors

Jj Harris
Greenhorn

Joined: Apr 17, 2010
Posts: 4
I have 3 classes so far of JFrames. When i call one it works fine but when I click a button to call another one then the JFrame comes up blank. Heres my 3 classes of code so far.



Jj Harris
Greenhorn

Joined: Apr 17, 2010
Posts: 4
this is just a start of it but you can tell what im trying to do at some points of it.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Jj Harris wrote:this is just a start of it but you can tell what im trying to do at some points of it.


Actually, it's a lot of code to ask a volunteer to go through. Someone might review it and help you, but if you shrink your problem and your code down a bit, your chances of getting help increase greatly. I suggest that you create a very simple JFrame and then try to show another simple window (I usually use a JDialog in this situation) from some action (menu or button) that occurs on your simple JFrame. This way both you and we will be able to see much more easily just what you are doing correctly vs. incorrectly.

Edit: also, if you use code tags when posting your code, the code will retain its formatting and be much easier to read. The Forum's FAQ's can help you with this.

Edit2: Oh, and welcome to the Ranch!

Edit3: Don't compare Strings like this:

Instead use either the equals or the equalsIgnoreCase method:


Much luck!
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
OK, I went through some of your code, and I've found several significant problems in your code:
  • Using == to compare two Strings rather than the equals or equalsIgnoreCase
  • Using deprecated methods
  • Having a semicolon after an if condition which will make the if condition fail:


  • Setting actionCommands and not using the correct Strings when testing for them
  • Recursively creating a new MainForm rather than setting the original MainForm to visible when you want it to appear.
  • And your main problem: Creating a RepresentingMotionEquationsSelection object, but not telling it to fill its menus and contentPane. You forget to do this:



  • Minor issues
  • using JFrames as JDialogs
  • Using a single ActionListener (this) for all buttons and menus
  • Using String literals instead of String constants in your actionCommands: it's easy to make mistakes here
  • Not creating a very small proof of concept application that tries to solve your current issue in a simple and small compilable program


  • Best of luck, and please acknowledge that you've read this because it did quite a bit of time to go through your code.

    /Pete
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    An example of a small program to demonstrate functionality:

    Jj Harris
    Greenhorn

    Joined: Apr 17, 2010
    Posts: 4
    thank you for the assistance I will try this and see if it works
    Jj Harris
    Greenhorn

    Joined: Apr 17, 2010
    Posts: 4
    I got a new error now. The DeltaTTfTi class is getting StackOverFlowError with my Container d
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    Jj Harris wrote:I got a new error now. The DeltaTTfTi class is getting StackOverFlowError with my Container d


    Sounds like time to do a little debugging. Are you recursively creating a new MainFrame anywhere? Do you have a debugger (one comes with Eclipse or NetBeans)? Have you tried placing println statements around to test the state of variables during program running and to see what gets called when?

    If you are unable to find the bug, then create a small program similar to my code above that demonstrates your problem and post it here. As it is, you are posting a problem without giving us any information that can help us solve the problem.

    Best of luck on your success.
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10170
        
        8

    Please UseCodeTags


    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Calling Classes of JFrame errors
     
    Similar Threads
    Trying to figure out Exception Error in code
    Problems with this weeks code..Still not understanding Illegal start of expression...HELP PLEASE
    Running errors ins MyMusic.java program
    comboBox problem need help bad
    Create Swing Program