Netbeans & Swing & Events

Posted on 2007-10-09
Last Modified: 2013-11-23
I have a specific Swing question about events, and then a more general question...

Question #1:  I have created a JFrame/JTabbedPane/JPanel window.  Immediately after this frame opens, I want to execute some setup code right before handing off the window to the user for input.  To which component/event should I attach my code?

Question #1:  I am using the latest Netbeans IDE.  I would like some comments to help me understand the interplay between Netbeans & Swing, and how much Netbeans-specific content Netbeans creates.  It is my understanding that questions like #1 above do not relate to Netbeans specifically, because even though the code was generated by Netbeans, the code generated is Swing code.  Is this true?  
Question by:LarryAndro
    LVL 86

    Accepted Solution

    1 Use a WIndowListener on your frame:

    2. You needn't worry - one of the good things about NetBeans is that the code it produces is generic
    LVL 1

    Author Comment

    It looks like WindowOpened is the specific WindowListener event to use.  Good to know I should attach it to the JFrame too.  

    I'm glad Netbeans doesn't add Netbeans-specific code.  I'll ask future questions as plain old Swing questions, unless my question is about the Netbeans interface.

    Thanks for assistance.
    LVL 86

    Expert Comment



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Java MSI Solution 3 51
    wordsCount challenge 10 49
    java set up 1 35
    groovy example issue 10 31
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now