
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to create rounded borders in Swing
Let us first create a Frame:
JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true);
Now, create rounded borders:
double x = 50; double y = 50; frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50));
The following is an example to create rounded borders in Swing:
Example
import java.awt.geom.RoundRectangle2D; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JPanel { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true); double x = 50; double y = 50; frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50)); frame.setSize(600, 500); frame.setLocationByPlatform(true); frame.setVisible(true); } }
Output
- Related Questions & Answers
- Java Program to create JCheckBox from text in Swing
- Create translucent windows in Java Swing
- Create Toast Message in Java Swing
- Create shaped windows in Java Swing
- Create gradient translucent windows in Java Swing
- Create a simple calculator using Java Swing
- Add rounded borders to first and last link in the pagination using CSS
- How to create two borders for a single component in Java?
- Java Program to use Soft Bevel Border in Swing
- How to create CSS3 Rounded Corners?
- Java Program to add Titled Border to Panel in Swing
- Java Program to append a row to a JTable in Java Swing
- Create rounded image with CSS
- Program to combine BorderLayout, GridLayout and FlowLayout in Java Swing?
- How to create and style borders using CSS?
Advertisements