The DecoratedComponentsProject is a lightweight Java Swing library designed to simplify the creation of visually appealing UI components. The library currently provides two powerful components:
- DecoratedPanel
- DecoratedImagePanel
This library is a perfect choice for developers looking to enrich their Swing applications with enhanced visuals without compromising performance.
⁜ IDE drag & drop designing support (Netbeans).
⁜ Easily understandable property customization.
🖼️ DecoratedPanel
- Customizable rouded corners and background colors.
🌄 DecoratedImagePanel
- Display images seamlessly with advanced scaling options.
- Smooth rendering for high-resolution images.
Installation
Simply download the .jar file and Add the library to your project.
The usage is pretty self explanatory since it is easy with Netbeans IDE. (Explained usage instructions will be added sooner!)
- Create a new DecoratedPanel Object and set border radius as needed:
import com.rajaguru.DecoratedPanel;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame("DecoratedPanel Example");
DecoratedPanel panel = new DecoratedPanel();
panel.setBackgroundColor(Color.BLUE);
//To set Top-Left Radius
panel.setArchTopLeft(100);
//To set Top-Right Radius
panel.setArchTopRight(100);
//To set Bottom-Right Radius
panel.setArchBottomRight(100);
//To set Bottom-Left Radius
panel.setArchBottomLeft(100);
frame.add(panel);
frame.setSize(800, 800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}- Create a new DecoratedImagePanel Object and set the Image:
import com.rajaguru.DecoratedImagePanel;
import javax.swing.*;
import javax.swing.ImageIcon;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame("DecoratedPanel Example");
DecoratedImagePanel panel = new DecoratedImagePanel();
//Add Image to panel
panel.setImageIcon(new ImageIcon(getClass().getResource("path")));
frame.add(panel);
frame.setSize(800, 800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}- Set the border radius for DecoratedImagePanel:
//MAKE SURE TO SET THIS PROPERTY TRUE TO ACTIVATE THIS FEATURE
panel.setRoundedCorners(true);
//To set Top-Left Radius
panel.setArchTopLeft(100);
//To set Top-Right Radius
panel.setArchTopRight(100);
//To set Bottom-Right Radius
panel.setArchBottomRight(100);
//To set Bottom-Left Radius
panel.setArchBottomLeft(100);- To center image within the panel:
panel.setCenterImage(true);- To Fit the image to the container:
panel.setFitContent(true);- To Contain the Image withint the conrainer (New):
- This feature can be used along-side centerImage function as well.
panel.setContainContent(true);- To Enable Smooth Rendering of the image: This feature may slow down the loading process based on the performance of your workstation. How ever this will get rid of that laggy edges of the image if you need it.
panel.setSmoothDecoration(true);- Java Swing
- JDK 8+
- Wishva Rajaguru @ wishvarajaguru@gmail.com
Connect with me on GitHub !
This project is licensed under the MIT License. See the LICENSE file for details.
If you find this project helpful, please ⭐ the repository and share it with others!