Timed Jpanel Popup

Posted on 2006-06-06
Last Modified: 2012-08-13
I'm looking to make a Jpanel (or JDialog) that will popup for around 3 seconds displaying some text that it is given and then dissapear without any user interaction.

I am able to make a panel that will appear as a popup, but I am unable to figure out how to get the panel to close on it's own after a certain period of time.
Question by:FutureTechWest
    LVL 24

    Expert Comment

    You can set a timer and    panel.dispose()   on it.
    But what you describe ... could be a tooltip.

    LVL 14

    Accepted Solution

    You can use javax.swing.Timer to achieve this behaviour:

    final JDialog jd = ...
    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
    Timer t = new Timer(3000, al);

    after creating dialog and timer, show the dialog and start the timer:

    LVL 14

    Expert Comment

    glad to help

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    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…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

    755 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

    26 Experts available now in Live!

    Get 1:1 Help Now