Is it possible to use Post Processing effects like gaussian blur or greyscale effects on an entire JFrame independent from its contents?
I would guess you are looking at the JLayer class. See How to Decorate Components with the JLayer Class for more information and examples.
Another option might be to use a Glass Pane. See the glass pane demo from How to Use Root Panes.
Related
I have created a JFrame - now I want to add the 4 JPanel in that frame at a particular location. How can set the location of panels in the frame?
Use (possibly nested1) layouts for the logic. See Laying Out Components Within a Container for details. They can:
Include default spacing in the constructor (often)
Calculate how big the GUI needs to be in order to display the components (in whatever PLAF, on whatever system the app. is deployed).
Extra spacing can be organized by adding an EmtpyBorder to child components.
See the nested layout example
Placing components in a container is quite a complicated subject in Swing. Instead of defining the exact places for your components, you would normally use a layout manager that arranges them in a certain way.
Here is the tutorial you should read to get a (visual) clue about the different layout managers: A Visual Guide to Layout Managers
However, the standard layout managers of Swing can be cumbersome for more complex layouts. Either, you could use nested layouts to get the desired result, or you could use a very powerful third-party library: JGoodies Forms. The downside is of course that you have to learn yet another library. Therefore, I would only recommend it for a bigger project.
For me it is good way to set GridbagLayout for the container of the frame. There are several visual swing GUI editors available to do this easily. You can use NetBeans GUI editor or GWT Designer (https://developers.google.com/web-toolkit/tools/gwtdesigner/) for complex GUI designing tasks
If its 4 locations, you can use BorderLayout,by default its the CENTRE, but it also have EAST, WEST , NORTH, SOUTH locations for the placement of the components. You can also use setLocation to put the panels in the appropriate locations, if a layout isn't used.
Its even better to use GroupLayout developed my NetBeans team in 2005, use Windows Builder Pro, now provided by google for free.
set the layout of the Frame to be null via setLayout(null)
create 4 JPanel and set their location using setLocation method
add these panels using JFrame's add method
I want to draw a line between different components in a JPanel, but the line should be a component, ie, it can be clicked, highlighted, selected and deleted instead of just painting a line in a panel, is there anything like this or I must implement it by myself. And if I must implement it, how?
You could use a JSeparator. But you'll have to implement the click, highlighting, selection and deletion yourself. A JSeparator is just use to... separate sections in a panel.
If you mean that all these operations should be available when designing your GUI in a wysiwyg editor like NetBeans Matisse, then JSeparator is just what you need.
I tried to use prepared things like JSeparator, But I found the best way by myself and I implement it. I used a JLayeredPane for my container. I add my own JPanel behind the all layers and override its paint() method. in paint() method I used Java2D to draw a curve between Components on higher layers in JLayeredPane. You can see the result in below.
Is there any component in Swing(X) by which we can place a veil loading image over a panel or frame making it transparent during some lengthy background processing?
Few examples of Romain Guy's work:
Chapter 9 of “Filthy Rich Clients” book, with downloadable code
SwingFX: Pretty Progress Panels
Glasspane Painting
GlassPane Intercepts
And other example:
GlassExample
You're looking for the Glass Pane, work through the tutorial here and the relevant section here
You need to add a glasspane to the frame, thats right. But you also can use SwingX' JXFrame and simply set a waitpane and activate it when a loading action starts.
Have a look at the API
I have a JPanel with one component that I want to place in an absolute sense, whereas the rest of the components are placed according to a layout manager.
Is there a simple way to do this?
Are you saying you want a component painted over top of all the other components? If so then you would need to use a JLayeredPane.
Why don't you post a SSCCE that demonstrates what you want to do?
You can add components to a frame as you would do normally and make the frame visible. Then you can add this random component and use setBounds on the component. As long as you don't revalidate() the panel or resize the frame we will be able to see how you intend to position this component relative to all the other components.
You might also want to look at OverlayLayout, seen here. For some reason it's excluded from the conventional gallery, but it may be of interest.
You can do this with only needing one JPanel using MigLayout
I have a JFrame that has a JLayeredPane. The JLayeredPane contains a heavyweight component (Ardor3d AWT canvas). I am trying to display a JPanel on top of the heavyweight component. This works perfectly until I set the size of the frame to the size of my monitor. The heavyweight seems to draw over the Jpanel that I want on top.
Any ideas?
This might help you: http://java.sun.com/developer/technicalArticles/GUI/mixing_components/
Yes, this is why you should not mix heavyweight and lightweight components. Extend JComponent and override paintComponent() instead of using a canvas.
You mention Ardor3d, I assume that is some sort of 3rd party component. If there is not a Swing version I would suggest finding something else to meet your need.