- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to arrange components in a Flow to be right-justified in Java?
Use FlowLayout.RIGHT to arrange components in a FlowLayout to be right-justified. −
JFrame frame = new JFrame("Language"); frame.setLayout(new FlowLayout(FlowLayout.RIGHT));
The following is an example to arrange components in a flow to be right-justified −
Example
package my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Language"); frame.setLayout(new FlowLayout(FlowLayout.RIGHT)); JLabel label = new JLabel("Most Spoken Language "); label.setPreferredSize(new Dimension(220, 70)); label.setOpaque(true); label.setBackground(Color.RED); label.setForeground(Color.WHITE); Font font = new Font("Serif", Font.BOLD, 14); label.setFont(font); label.setHorizontalAlignment(JLabel.CENTER); JTextArea text = new JTextArea(); text.setText("India"); font = new Font("Serif", Font.BOLD, 13); text.setFont(font); frame.add(label); frame.add(text); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(600, 300); frame.setVisible(true); } }
OutPut
- Related Articles
- How to arrange components in a FlowLayout to be left-justified in Java?
- How to ceate right justified JTextField in Java?
- Java program to lay out components in a flow to be centered with FlowLayout?
- How to set the text of the JLabel to be right-justified and vertically centered in Java?
- How to set the content of the label to be right-justified and top-aligned in Java?
- How to create a Box to display components from left to right in Java
- Java Program to set the content of the JLabel to be right-justified and bottom-aligned
- How to get a space-padded string with the original string right-justified in Python?
- Set the content of the JLabel to be left-justified and top-aligned in Java
- How to create JSplitPane to divide components in Java?
- Arrange the following boxes in proper order to make a flow chart of sugarcane crop production.
- How to add components with a Relative X Position in Java
- Java program to set the content of the JLabel to be left-justified and bottom-aligned
- How to deal with reusable components in Selenium Java?
- How to set a different look and feels to swing components in Java?

Advertisements