Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: [HELP] Call JInternalFrame Trouble

  1. #1
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question [HELP] Call JInternalFrame Trouble

    Dear All ,

    Please its support , I have problems to call JInternalFrame from JInternalFrame ,
    Here I am Using one JFrame and JDesktopPane as its ContentPane , then 2 JInternalFrame , following his pieces Coding :

    JInternalFrame 1
    / / Coding I created this in order to avoid double JInternalFrame which appear
    private static JInternalFrame1 myInstance;
        public static JInternalFrame1 getInstance() {
            if (myInstance == null) {
                 myInstance = new JInternalFrame1();
            }
        return myInstance;
    }
     
    JInternalFrame 2
    / / This comes from ActionPerformed Coding Button Add to call JInternalFrame 1
    private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {                                          
            // TODO add your handling code here:   
            JInternalFrame1 rd = JInternalFrame1.getInstance();
            if(rd.isVisible()){
               rd.toFront();
               rd.requestFocus();
            }else {          
            JFrame.JDesktopPane.add(rd); 
            rd.setVisible(true);  
            }     
        }

    Either Netbeans bugs or not , the first time Button Add be pressed , JInternalFrame1 appear without any problems , and if JInternalFrame1 closed (using dispose()) and then press again the Add Button appear the error :
    "Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal component position"

    Please its support ,
    Thanks ,
    Best & Regrads


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: [HELP] Call JInternalFrame Trouble

    Please provide a short runnable example that demonstrates the problem.

    It's not clear what you're doing, but if you're deleting components in a container, then adding new components in place of the deleted ones, you may need to revalidate() the container.

  3. #3
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [HELP] Call JInternalFrame Trouble

    Quote Originally Posted by GregBrannon View Post
    Please provide a short runnable example that demonstrates the problem.

    It's not clear what you're doing, but if you're deleting components in a container, then adding new components in place of the deleted ones, you may need to revalidate() the container.
    JInternalFrame2 is a Transaction Window & JInternalFrame1 is a Transaction Detail Window, When Add Button pressed in JInternalFrame2, JInternalFrame1 is showing. I use method getInstance() that i create to make sure only one JInternalFrame1 Window exist , piece of code attached above.

    But an error occurs, here is the error say in NetBeans : "Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal component position"

    Sorry for my bad English, I try to explain it as easy as possible.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: [HELP] Call JInternalFrame Trouble

    Please make a Short, Self Contained, Correct Example and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: [HELP] Call JInternalFrame Trouble

    Your English is fine. Don't sweat that.

    Netbeans is a fancy editor and graphical interface for building GUIs, if used that way. The description of an error as a Netbeans error isn't really helpful. It is much more helpful if errors are identified as either syntax (usually highlighted by the IDE before compiling), compiler (errors that occur when trying to compile), run time (errors that occur after the program has successfully compiled while running the program), or logic (errors that cause the program's results to be other than desired or expected.)

    The error you've posted is not clear, because I cannot tell what code it is complaining about. I've read a few posts by others who've had the same error, and it's usually because the Container.add() method (in one of its many forms) has been used incorrectly, either specifying a position that doesn't exist or being used to add a component to a container that is already full. Investigate that as a possible reason for your error.

    If you can't post a short, runnable example that demonstrates the problem, it would be helpful to see the entire error message, copied from exactly as it appears at your end and pasted into a post, with the specific line(s) of code mentioned by the error.

  6. #6
    Junior Member
    Join Date
    May 2013
    Location
    Indonesia
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [HELP] Call JInternalFrame Trouble

    Quote Originally Posted by GregBrannon View Post
    Your English is fine. Don't sweat that.

    Netbeans is a fancy editor and graphical interface for building GUIs, if used that way. The description of an error as a Netbeans error isn't really helpful. It is much more helpful if errors are identified as either syntax (usually highlighted by the IDE before compiling), compiler (errors that occur when trying to compile), run time (errors that occur after the program has successfully compiled while running the program), or logic (errors that cause the program's results to be other than desired or expected.)

    The error you've posted is not clear, because I cannot tell what code it is complaining about. I've read a few posts by others who've had the same error, and it's usually because the Container.add() method (in one of its many forms) has been used incorrectly, either specifying a position that doesn't exist or being used to add a component to a container that is already full. Investigate that as a possible reason for your error.

    If you can't post a short, runnable example that demonstrates the problem, it would be helpful to see the entire error message, copied from exactly as it appears at your end and pasted into a post, with the specific line(s) of code mentioned by the error.
    Problem Solved, i'm switch from using JInternalFrame to using JDialog. but New Problem appear, i can't removeTableModelListener() on diferent JDialog. I will post the new problem in new post.

    Thanks all for the support,
    Best & Regrads.
    I Love Java Programming.

Similar Threads

  1. running jinternalframe
    By cnjiru in forum AWT / Java Swing
    Replies: 0
    Last Post: May 25th, 2012, 12:49 PM
  2. Replies: 1
    Last Post: September 26th, 2011, 07:23 AM
  3. Call by Reference & Call by Value
    By Lokesh in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2011, 01:19 PM
  4. [SOLVED] How to reload JInternalFrame
    By chyrl in forum AWT / Java Swing
    Replies: 7
    Last Post: April 6th, 2010, 06:31 AM
  5. Question about JInternalFrame
    By TimW in forum AWT / Java Swing
    Replies: 0
    Last Post: November 7th, 2009, 08:31 AM

Tags for this Thread