Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:29:24+00:00 2026-05-30T19:29:24+00:00

I was using swing to create a program/start menu for my java program. What

  • 0

I was using swing to create a program/start menu for my java program. What I want is for my program to play an animated GIF in the background, while an invisible button over a certain section of the gif (which only reveals its presence if you mouse over it). My problems are thus:

A) I am not sure how to get the animated gif to play while to program waits for a button press.
B) How do I make a JButton invisible?

Any help would be appreciated, thanks.

-JXP

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:29:25+00:00Added an answer on May 30, 2026 at 7:29 pm

    I never used gif or animated gif in the Swing, but you can use for that this code

    enter image description here enter image description here

    import java.awt.Insets;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.Icon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    
    public class MyToggleButton extends JFrame {
    
        private static final long serialVersionUID = 1L;
        private Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
        private Icon infoIcon = UIManager.getIcon("OptionPane.informationIcon");
        private Icon warnIcon = UIManager.getIcon("OptionPane.warningIcon");
    
        public MyToggleButton() {
            final JButton toggleButton = new JButton();
            toggleButton.setBorderPainted(false);
            toggleButton.setBorder(null);
            toggleButton.setFocusable(false);
            toggleButton.setMargin(new Insets(0, 0, 0, 0));
            toggleButton.setContentAreaFilled(false);
            toggleButton.setIcon((errorIcon));
            toggleButton.setSelectedIcon(infoIcon);
            toggleButton.setRolloverIcon((infoIcon));
            toggleButton.setPressedIcon(warnIcon);
            toggleButton.setDisabledIcon(warnIcon);
            add(toggleButton);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            setVisible(true);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    MyToggleButton t = new MyToggleButton();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m trying to create a desktop application using swing in java, which allows
I am trying to create a GUI using java swing. From there I have
I am using Java Swing to create a JDialog, and i am trying to
I am trying to create a java gui using netbeans but the swing panels
I'm working on a simple calculator program using java and javax.swing Basically, when you
I created a program with a Swing GUI in NetBeans a while back using
I've been attempting to create a pen tool for my Java drawing program using
I am writing a game using Java Swing. I want to paint each time
I am using swing to create my GUI. J have a JFrame containing one
I tried to create a new Swing GUI desktop application template using NetBean 7.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.