Results 1 to 2 of 2
  1. #1
    Jerba is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Question [JPanel] In window splash screen.

    Hello, I've been playing around with what i like to call an in window slash screen.

    I've been using the paintComponent method and using a swing timer, however, i don't believe this is the most efficient way to do it, if anyone knows a simpler way of doing it, or a better more efficient way of doing, please leave a comment.

    Thank-you.

    Current Code: Doesn't actually work... and i can't figure out why.
    package org.main;

    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.ImageIcon;
    import javax.swing.JPanel;
    import javax.swing.Timer;

    public class Splash extends JPanel {

    private static final long serialVersionUID = 1L;

    Image image;
    Timer timer;

    ImageIcon splash = new ImageIcon("res/splash.png");

    public Splash() {
    setFocusable(true);
    image = splash.getImage();
    timer = new Timer(3000, new LoadAction());
    repaint();
    timer.start();
    }

    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawImage(image, 0, 0, null);
    }

    class LoadAction implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
    if(image != null && timer != null) {
    image = null;
    System.out.println("Removed Drawing");
    repaint();
    }
    }
    }

    public Image getImage() {
    return image;
    }
    }
    Last edited by Jerba; 02-21-2013 at 07:35 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: [JPanel] In window splash screen.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Problem with splash screen
    By frintocf in forum AWT / Swing
    Replies: 1
    Last Post: 09-06-2011, 11:42 PM
  2. Splash Screen How?
    By bircastri in forum AWT / Swing
    Replies: 1
    Last Post: 11-16-2010, 04:51 PM
  3. Splash Screen
    By madcommu in forum SWT / JFace
    Replies: 4
    Last Post: 09-18-2010, 01:14 PM
  4. splash screen
    By joypik in forum AWT / Swing
    Replies: 1
    Last Post: 07-13-2010, 07:48 PM
  5. Splash Screen
    By Doctor Cactus in forum New To Java
    Replies: 1
    Last Post: 10-29-2008, 06:42 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
  •