This question already has answers here:
Swing application initialization and loading screen approach
(2 answers)
Making a loading screen in netbeans
(2 answers)
Closed 2 years ago.
I have a Java Swing program that has a lot of components and I want to implement a waiting animation that can be called on will (if it can be packaged all into one method call - not for just when the program begins). The idea is that I have two images that swoop in PowerPoint style --> wait for the components to be done --> the two images swoop out. I plan to do the animation for the two images in Java Swing (that is incrementing their x and y positions over time). Any ideas how I can go about this? I was thinking that I need a SwingWorker but I'm not very experienced with those. Is it even possible to know when Swing is done processing and painting all the components? Thank you.
Related
This question already has answers here:
how to use the layout managers in swing java
(3 answers)
Closed 3 years ago.
I have little experience with Java Swing. I'd like to ask if my idea of combining layouts to obtain a responsive app is the way to go in order to create a semi-responsive Swing app ("semi-" in the sense it should look good given a minimal screen resolution, say 800 x 600 pixels).
Yes, that's the way to go in standard Java without Libraries.
Personal Opinion:
I personally really dislike the LayoutManagers delivered in Swing (apart from the simple Flow and Border Layouts). Therefore I use MigLayout to do most of the Layout. This avoids having to combine multiple LayoutManager to position a single component. The learning curve might be a bit larger than with the simple Layouts, but I still think it's easier than GridBagLayout and can do a LOT more.
Once you get it the code will be super clean, as it works with Layout Constraints that (when using String Constraints) kinda is a graphical representation of your Layout Settings.
Here's a guide to get you started: http://www.miglayout.com/QuickStart.pdf
And here you can look up the commands you can use: http://www.miglayout.com/whitepaper.html
This question already has answers here:
How to go back to a JFrames in Java
(3 answers)
Closed 7 years ago.
When I open a new JFrame, I set the old one as false:
ExampleJFrame.this.setVisible(false);
ExampleNewJframe newOne = ExampleNewJframe();
newOne.setVisible(true);
But If I am in newOne, how do I get back to the original Frame without creating a new as I did above?
The best solution: don't go swapping JFrames; that's can be a rough design that can annoy users. Instead swap JPanel "views" using a CardLayout as per The Use of Multiple JFrames, Good/Bad Practice?.
This question already has answers here:
How to control the JavaFX Tooltip's delay?
(8 answers)
Closed 7 years ago.
I have tried Using
1)
import javax.swing.ToolTipManager;
ToolTipManager.sharedInstance().setDismissDelay(20000);
at various locations in *.java file (using NetBeans IDE)
2) Creating OnMouseEnter MouseEvent Handler Override routine including:
ToolTipManager.sharedInstance().setDismissDelay(20000);
Results: No Errors, Runs fine, Except Display Time is ALWAYS 5secs!!!
I would prefer NOT creating my own Popup Control, because I like all the Behavior of existing Tooltip, except Im trying to Display Several words in Tooltips that User Needs to take Long Time to Read. Please Help!!!!!
You're calling a Swing utility class, i.e. import javax.swing.ToolTipManager, this has no control over JavaFX functionality.
According to control JavaFX Tooltip delay, this is not supported and the subject of a change request. That question also contains a reflection based 'hack' and another workaround involving popups.
This question already has answers here:
JFrame in full screen Java
(14 answers)
Closed 9 years ago.
I've been Java applications on OS X, and haven't had the opportunity to fully test in different places.
There are 2 different JFrames. The second is loaded exactly in place of the first one, and as such needs to have its size and location set to the same as the first.
This works fine, but I noticed a lot of Windows users seem to maximise the first window. When the second JFrame loads, it has the same size, but is not "maximised".
Maximised windows in the MS Windows world have a slightly different state and are treated differently by the OS.
How can I tell if a JFrame is Maximised, and how can I maximise one myself?
frame.setExtendedState( f.getExtendedState()|JFrame.MAXIMIZED_BOTH );
This question already has answers here:
How to set Icon to JFrame
(12 answers)
Closed 6 years ago.
I want to know that how to change the image in the upper left corner in a java program and in the taskbar.
See the screenshot to know what i am talking about-
http://www.ougfiles.com/dl/303275944/Untitled.jpg
I think you're looking for Window.setIconImage, where the "window" will probably be a JFrame if this is a Swing app.
Note that there's also Window.setIconImages which allows you to set multiple images, so that it can pick up different resolutions for different situations (e.g. a bigger icon in the Windows task bar than in the frame itself.)
Use setIconImage() or setIconImages(). The latter lets you specify a list of icons in different resolutions; the most suitable one will be used in each case (desktop, taskbar, title bar of the frame, etc.)
See also the this section in the Java tutorial.
Quick Google searched revealed a setIconImage for your Frame
frame.setIconImage() (oracle.com)