I am making a game. On the first screen, its just asking for all of the details but i don't want the actual game visible in the background. How do i set it so all the stuff in the back isn't visible and the opening bit, and as soon as the user presses play, it all becomes visible. I assume you would use "earnings.setVisible(true); but its already true, how do i get it so it starts off with false when i load the gui up. Or is there a better way of approaching this issue? New window maybe?
Related
I'm making a game in Java Swing. Every time the player levels up I display a new frame on top of the one containing the gameplay which has some options on what rewards to get for having leveled up. Due to the nature of my rewards being able to skip choosing some of the upgrades could break the game, so I want to ensure that the user can only resume playing by clicking on one of the 1-3 buttons displayed in the level-up frame.
I have the frame set to undecorated and to appear always on top, but nothing's stopping the user from clicking outside of it to the main gameplay panel and simply pressing esc to resume playing. Instead I want it so the user can only click on the level-up frame out of the 2.
Is there an easy setting I can toggle for this, or do I have to remove remove my keyboard input listener from the first panel to achieve this?
We're making an app for one of my classes that is supposed to draw the interest of 4th-6th graders, so we're looking to make a game type environment. I'm looking to find a seamless way to transfer from one page to the other. I've found that if you try to close and open frames it jumps and looks less professional, I was just wondering if there was any way for it to just communicate between panels that if a button is pressed on a panel, it will set that panel's visibility to false and set another panel to true(as though it has changed screens).
This is most likely an obvious question, but I was wondering how I can keep a program behind all other windows (except the desktop)?
In a way, I am trying to achieve the opposite of keeping a window in the front.
Here's an example:
Window 1
Window 2
Random Window
My App
Desktop
However, I need it so that it will always stay against the desktop, so you cannot interact with it unless you're looking at the desktop itself.
public void toBack()here
If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.
Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.
4 Years late, but if you need the window to always stay in the back, even when the user clicks on it, you can use:
JFrame frame = new JFrame("");
frame.setFocusableWindowState(false);
frame.toBack();
setFocusableWindowState(false) prevents the activation of the window when clicked.
Context: in my Java Swing app I have a chart (using JFreeChart) and when the user clicks on a datapoint on it, it opens a specific flash animation in a JDialog (flash played using DJNativeSwing).
Problem: when the flash animation starts playing, for some reason the background chart in the main window decides to refresh (calls its paintComponent()) and, as the chart is fairly heavy, this takes ~4 seconds during which the flash animation freezes.
I am thus looking for the most elegant / simplest solution to avoid the flash freeze. So far, I could imagine:
Find out why paintComponent() is called and avoid this
Open the JDialog (or child window without modal behavior) on a different thread
What would be the best approach and, most importantly, how to do it?
I have been playing around with trying to get a menu screen for my game. I have only been able to figure out how to paint a new Screen on top of an existing one; meaning that the actual game is still running behind the title screen. I don't need actual code but just a description of how I would go about this.
One way to display a menu would by by using a JDialog outside of your main application window. Take a look at the How to Make Dialogs tutorial for more information.
Another possibility would be to use JInternalFrame for your game and menu so they can be wrapped in a larger application frame. These are explained nicely in How to Use Internal Frames