Java provides different functions by which we can control the translucency of the window or the frame. To control the opacity of the frame the frame must not be decorated. Opacity of a frame is the measure of the translucency of the frame or component.
In Java, we can create shaped windows by two ways first by using the AWTUtilities which is a part of com.sum.awt package AWTUtilities class have a function – setWindowShape(Window w, Shape s) which sets the shape of the window and second by using setShape(Shape s) which sets the shape of the window to the specified shape.
In this article we will discuss about uniform translucency of window.
Methods used :
- setWindowShape(Window w, Shape s) : sets the shape of the window w to the specified shape s
- setShape(Shape s) : sets the shape of the window to the specified shape s
- setOpacity(float f) : sets the value of opacity of the frame
1. Program to create a translucent frame and control its translucency with the help of a JSlider
2. Program to create a shaped translucent window (using AWTUtilities)and control its translucency using a slider
3. Program to create a shaped translucent window (using setShape)and control its translucency using a slider
Note : The above programs might not run in an online compiler please use an offline IDE. It is recommended to use latest version of java to run the above programs, user might face problems if older versions of java are used.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- JSwing | Create Translucent and Shaped Windows in Java
- Java Swing | Look and Feel
- Java Swing | BevelBorder and SoftBevelBorder
- Java Swing | Popup and PopupFactory with examples
- Difference between AWT and Swing in Java
- Java Swing | ScrollPaneLayout Class
- Java Swing | JPanel with examples
- Java Swing | Internal Frame with examples
- Java Swing | JMenuBar
- Java Swing | JFileChooser
- Java Swing | JTextField
- Java Swing | JProgressBar
- Java Swing | JPasswordField
- Java Swing | JSpinner
- Java Swing | JPopupMenu
- Java Swing | JTextArea
- JLabel | Java Swing
- Java Swing | JToolBar
- JRadioButton | Java Swing
- Java Swing | ToolTip
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.