Results 1 to 8 of 8
  1. #1
    shurgs is offline Member
    Join Date
    Aug 2010
    Location
    England
    Posts
    12
    Rep Power
    0

    Default Opening a Form Compile Error

    I'm trying to open the form "LizRotaAddEvent.java" from my main form "LizRotaView.java" using a menu item which I've linked to the action shown below in Netbeans/Swing.

    This is in my program's main form.

    Declaration:
    Java Code:
    private JDialog addEvent;
    Show Form Action:
    Java Code:
       @Action
        public void showaddevent() {
            if (addEvent == null) {
                JFrame mainFrame = LizRotaApp.getApplication().getMainFrame();
                addEvent = new LizRotaAddEvent(mainFrame);
                addEvent.setLocationRelativeTo(mainFrame);
            }
            LizRotaApp.getApplication().show(addEvent);
        }
    And this is in the form I'm trying to open:
    Java Code:
    package lizrota;
    
    import org.jdesktop.application.Action;
    
    public class LizRotaAddEvent extends javax.swing.JDialog {
    
        public LizRotaAddEvent(java.awt.Frame parent) {
            super(parent);
            initComponents();
    
            }
    And the start of the container code:
    Java Code:
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
    I get these errors with then a load of esoteric jargon after each when I go to open the form.
    "Exception in thread "AWT-EventQueue-0" java.lang.Error: java.lang.reflect.InvocationTargetException" and "GroupLayout can only be used with one Container at a time".

    I can open a different frame with more or less exactly the same code without any errors. I'm totally stumped on this one. Any ideas would be greatly appreciated.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    shurgs is offline Member
    Join Date
    Aug 2010
    Location
    England
    Posts
    12
    Rep Power
    0

    Default

    Yeah, I can't see how it's being used twice though. And Swing doesn't let you edit generated code which is really irritating :( Guess if I open up the source code in notepad and edit it from there I can mess around with it until it works. One second...

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    On stack you can see where it happen. Can you post the complete stack trace?

    What you mean by not allowed to edit generated code, are you working on NetBeans ?

  5. #5
    shurgs is offline Member
    Join Date
    Aug 2010
    Location
    England
    Posts
    12
    Rep Power
    0

    Default

    Yeah, I'm working with netbeans. I intend to move to eclipse for my next Java project.

    I've found the offending code, but I don't know how to get around the problem. How are you supposed to have two containers if you can't lay out your components?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    If you've knowledge enough with NetBeans you can edit the *.form file, it's in XML format. DO NOT change it if you don't have an idea.

  7. #7
    shurgs is offline Member
    Join Date
    Aug 2010
    Location
    England
    Posts
    12
    Rep Power
    0

    Default

    If I could I would hug you! It's working now :D
    Ok, thanks for the pointers!

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Error While Opening A PDF file
    By Cluster Storm in forum AWT / Swing
    Replies: 6
    Last Post: 06-07-2010, 07:03 PM
  2. opening a Jframe form in a top of a new form
    By Nubkadiya in forum New To Java
    Replies: 7
    Last Post: 06-01-2010, 09:21 PM
  3. Replies: 1
    Last Post: 12-18-2009, 07:18 PM
  4. Replies: 1
    Last Post: 10-26-2009, 05:38 PM
  5. Compile Error - Please Help!!
    By AJ2009 in forum New To Java
    Replies: 10
    Last Post: 01-04-2009, 04:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •