does anybody know of any open source implementation of a JTabbedPane in which I can set a busy graphic (say spinning ball) on the tab, while I load something into the tab - much like the spinner on Firefox tabs.
I realize I could do this by hand by creating an animated GIF and setting it as an icon on the tab - but i was hoping that there'd be something that already did this.
Netbeans supports busy-icons when you create a new Desktop Application.
I zipped them and uploaded them.
Here is the link.
With this icons you can make a thread witch update the icon by calling.
JTabbedPane.setIconAt(int tabnumber, Icon icon);
See the method documentation: javax.swing.JTabbedPane.setIconAt(int index, Icon icon).
Hope this helps
I'd stick to the GIF89a idea. You'll need the single images, that are displayed in the animation, anyway, so why not wrapping them up into GIF89a (assuming that swing supports animated GIF on tabs) instead of flipping them manually (and fighting the Swing threading challenge)
Related
I'm about to write a program using Java and i want it to have the next behavior:
Start with a small screen, just one button (i'm going for the JMenuBar) for the user to select a image file (a country or state map)
Once selected the image file, i'll need to resize the frame to the size of the selected image, and put the image as background.
when the user clicks somewhere inside the frame (click on a state or city) the program will have to create a visual object there, a circle, square or any form in that coordinates.
will need also a listener in those objects to know when they are clicked.
Summary: User has to select an image and trace a graph on it.
I am not asking for the code to do this. I would like to have some ideas about which components use to achieve this since i have been reading and there are plenty of ways to set the background image and stuff. But, considering the requirements, can you recommend me which components to use? I am a bit short of time since i've been given only about a week to code this, otherwise i would try all the alternatives by myself.
Some answer like:
"use a label to set the background and then resize the frame by this way: (some stuff) and then you can create a class extending from JLabel to create the circles with the listeners...." that would be enough help
I hope I was clear, any idea is welcome
Many thanks!
If you're going to stick with Swing I would use a JFileChooser to select the image. Once you got the image you can easily resize the JFrame by using the frame.setSize(image.getWidth(), image.getHeight());
To listen for mouse clicks inside your JFrame you need to use a MouseListener, make sure to add it to the frame, I always forget doing that.
Not sure whether you've succeeded drawing images/shapes at all. If not, you need to use a JPanel, check this topic if you need extra help.
If you are going to use a "JFrame " then you should definitely use Swing JFrames JPanels, and JLabels (as well as any other JComponents you need.) to accomplish this. Use only one JFrame. Use JPanel as the content pane/background for your JFrame and add everything else to it. But I would also suggest learning and using JavaFX because its the newest and I think it would be the easiest to use to do something like this. But if you only have a week and you know some swing use what you know. If you need more information post some code. Or ask a more direct question.
I need to know how to select a layout for a java swing application with multiple windows.
It has a dashboard kind home or main window with few icons(12 or more) on it. Clicking on an icon it will open a complex window on top of it then the main window is no longer visible. There will be another home icon to get back to main window on new view. Complex in the sense the opened window will have a tabbed layout. What i need to know is what layout should I use for this purpose.
Card layout and layered layout are the candidates I suppose. Or should I use separate frames or is there some other option available.
If the window can take the full screen and position the icons on it zooming appropriately according to the screen size would be great.
I'm glad if you can provide me a reference to a sample code.
Thank you in advance for helping me out.
I suppose you want to hide home screen when user opens another screen, and show it again when user clicks something like "Home" button.
For similar thing, I used JLayeredPane. It essentially allows you to sat Z-order for your components. In this case, you would have a JPanel for each screen you want to show, and you need to place it inside JLayeredPane, with home screen being initially on top. When you want to show another screen, you set it's layer to be topmost.
My JavaFX applications look even more different between Windows and OSX than I'd like, as the title text on the mac is centered, but on Windows its left aligned. Ideally I want to make both centered.
Compare OSX
http://i.imgur.com/48YGy5D.png
with Windows:
http://i.imgur.com/alvWo2n.png
Of course, I'd like to know if anyone has found a way to get around this default?
Many thanks,
The best way I have found is to make an undecorated window and add my own title bar to the top of the frame, this way I have full control over everything and the OS/platform will never interfere with the layout.
See here for more info on one way you could do this:
How to create customize title bar with close button on jFrame?
So when I start up Netbeans, they create a little panel on the desktop for showing the progress of loading. I'm pretty sure Microsoft Office 2010 uses this too. I was curious how to make one of those in java?
I looked through the API and saw JDesktopPane. But I don't think that's what I'm looking for unless you can take that and put in on the actual desktop, but I'm unsure. Thanks in advance!
you can actually do it using JPanel.. you don't need to do anything else..no need of desktop pane
all you need to do is design a JPanel and put a progress bar inside it that will link to a process and show how much it has been completed.
JPanel doesn't have normal frame functionality like minimize, Close etc and will act exactly as you are trying to make up.
Update : Just tried doing what you wanted.
You need to start working on JFrame. and set its decoration to false.
in Netbeans, you can just go to Frame properties and set Undecorated to true
or inside code you can just write setUndecorated(true);
then you have to design your frame, put a progress bar inside it, link it to a function, set its onTop value to true (which means it will always be on top) and set its position to center of screen. done!! you are ready with your window!!
I'm trying to allow the user to change the title of a window in Java without adding components to the window itself. I'm actually trying this with a JInternalFrame, but figure the solution should be similar for a JFrame. I simply want to add an additional menu item in the context menu that pops up when right clicking on a window title bar. For example, the Set title below:
This example is on Windows XP, but perhaps there's a way to get the window context menu OS independently perhaps similar to the SystemTray.getSystemTray() (but for individual windows within an application). From this I would be able to provide my own ActionListener to popup a dialog for the user to enter a new title.
Is this a much bigger task than I'm guessing it is? Does anyone have solutions they've used before?
Short answer: I don't think this is easy. I'm not 100% sure if it is possible.
First, JFrame and JInternalFrame are actually quite different. JFrame is a top level component whose title bar and such are typically provided by the OS. JInternalFrame's entire content (including title bar) is provided by the Swing LAF.
For a JInternalFrame, the context menu is provided by the LAF, not JInternalFrame itself. You would have to do something with the UIComponent in order to change the context menu. I think you would likely have to provide a custom UI component in order to do this, which is ugly and typically breaks across different LAFs or works but looks terrible at best. See BasicInternalFrameTitlePane, the createSystemMenu method.
I don't think this is possible without digging way too deep into Swing's internal UI system and I wouldn't even consider doing this. Why don't you use the inbuilt JMenuBar of JInternalFrame?
myInternalFrame.setJMenuBar(myMenuBar);