Reputation: 325
I am trying to make a game for my semester project. I want to show a transition when user clicks on options button of my game menu or when user clicks on credits button. I want to show transition when one panel replaces another. Is it even possible? I am using java swing library.
Upvotes: 0
Views: 1448
Reputation: 285470
You should use a CardLayout to swap views (JPanels) in your GUI. To get a fade effect is not the most simple thing to do, but it can be done with a little work. I've done it successfully here where I create a special class called SwappingImgPanel that extends JPanel, and that fades one image into another using a Swing Timer. Specifically, the program does this:
swap()
on the SwappingImgPanel instance.done()
method is called which sets the SwappingImgPanel's State to State.DONE.Upvotes: 3