LightBox.jar --- Jar that helps you providing light box like effect in your desktop application built in swing.
You may have seen light box effects on a website but very rarely have seen light box effect in a desktop application specifically in applications that are built in java swing. This jar helps you put light box like effect into your swing application. So now you can also give same light box effect as on your website to your desktop application made in swing.

It’s very simple and easy to use this jar. You just have to create a instance of LightBox class and then call createLightBoxEffect() method on it with desired parameters and have a light box effect in your frame with a JPanel as popup.
This jar contains following 4 classes:
LightBox.java
- Main class that helps in providing light box like effect using JFrame and JPanel.
LightBoxUtil.java
- Light box utility class that contains utility methods like giving buzz effect to frame, blinking frame on taskbar, making beep sound, etc.
LightBoxMouseListener.java
- If light box is modal then this listener will be added to light box so that all mouse clicks and other mouse events comes in this class and not get passed to underlying components. This is the simplest way I thought about making light box effect modal.
LightBoxException.java
- Exception class for Light box effect jar.
Following is the description of constructor and methods of the class used to provide light box effect in this jar:
Constructors:
public LightBox()
Creates new LightBox instance. By default the lightbox effect is modal.
public LightBox(boolean modal)
Create new LightBox instance. If modal then all components under light box effect will be not able to generate any event until light box panel is closed.
Parameters:
modal – Whether to make light box effect modal or not.
Methods:
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel)
To give a light box effect.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, int panelLocX, int panelLocY)
To give a light box effect and show pop up panel on specified location.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
panelLocX – X value of location of panel.
panelLocY – Y value of location of panel.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, boolean blink, boolean makeSound, boolean buzzFrame)
To give a light box effect with blinking of window on task bar, plays a beep sound and gives buzz effect to frame.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
blink – Whether to blink frame on taskbar or not.
makeSound – Whether to make beep sound or not.
buzzFrame – Whether to give buzz effect to frame or not.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, int panelLocX, int panelLocY, boolean blink, boolean makeSound, boolean buzzFrame)
To give a light box effect with blinking of window on task bar, plays a beep sound and gives buzz effect to frame. Also shows pop up panel on specified location.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
panelLocX – X value of location of panel.
panelLocY – Y value of location of panel.
blink – Whether to blink frame on task bar or not.
makeSound – Whether to make beep sound or not.
buzzFrame – Whether to give buzz effect to frame or not.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, int panelLocX, int panelLocY, java.awt.Dimension size) throws LightBoxException
To give light box effect with specified size of light box shade panel and pop up panel’s location.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
panelLocX – X value of location of panel.
panelLocY – Y value of location of panel.
size – Size of the light box shade panel.
Throws:
LightBoxException – If given size of shade panel is not proper then this exception will be raised.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, java.awt.Dimension size) throws LightBoxException
To give light box effect with specified size of light box shade panel.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
size – Size of the light box shade panel.
Throws:
LightBoxException – If given size of shade panel is not proper then this exception will be raised.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, int panelLocX, int panelLocY, boolean blink, boolean makeSound, boolean buzzFrame, java.awt.Dimension size) throws LightBoxException
To give light box effect with specified size of light box shade panel with additional property flags like playing a beep sound, buzz frame, blink frame on taskbar.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
panelLocX – X value of location of panel.
panelLocY – Y value of location of panel.
blink – Whether to blink frame on task bar or not.
makeSound – Whether to make beep sound or not.
buzzFrame – Whether to give buzz effect to frame or not.
size – Size of the light box shade panel.
Throws:
LightBoxException – If given size of shade panel is not proper then this exception will be raised.
public void createLightBoxEffect(javax.swing.JFrame frame, javax.swing.JPanel panel, boolean blink, boolean makeSound, boolean buzzFrame, java.awt.Dimension size) throws LightBoxException
To give light box effect with specified size of light box shade panel with additional property flags like playing a beep sound, buzz frame, blink frame on taskbar.
Parameters:
frame – Frame on which light box effect will take place.
panel – Panel that will be shown as a pop up in light box effect.
blink – Whether to blink frame on task bar or not.
makeSound – Whether to make beep sound or not.
buzzFrame – Whether to give buzz effect to frame or not.
size – Size of the light box shade panel.
Throws:
LightBoxException – If given size of shade panel is not proper then this exception will be raised.
public void closeLightBox( javax.swing.JFrame jFrame, javax.swing.JPanel jPanel)
Exist light box effect.
Parameters:
jFrame – Frame on which light box effect has taken place.
jPanel – Panel that is shown as a pop up in light box effect.
Links:
- Swing light box source code and test class are shared here.
Feel free to comment for any query or information regarding this jar on this site.
2 thoughts on “Lightbox Jar”