
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 131 Articles for Swing

3K+ Views
A GridBagLayout is a very flexible layout manager that allows us to position the components relative to one another using constraints. Each GridBagLayout uses a dynamic rectangular grid of cells with each component occupying one or more cells called its display area. Each component managed by a GridBagLayout is associated with a GridBagConstraints instance that specifies how the component is laid out within its display area. GridBagConstraintsWe can customize a GridBagConstraints object by setting one or more of its public instance variables. These variables specify the component location, size, growth factor, anchor, inset, filling, and padding.gridx: An int value that specifies the leftmost cell that the ... Read More

7K+ Views
In this article, we will learn to implement the paintComponent() method of a JPanel in Java. In Swing, custom rendering of components is achieved by overriding the paintComponent() method. What is a JPanel? A JPanel is a lightweight container and it is an invisible component in Java. A JPanel's default layout is FlowLayout. After the JPanel has been created, other components can be added to the JPanel object by calling its add() method inherited from the Container class. What is a paintComponent() Method? The paintComponent() method is needed to draw something on a JPanel other than drawing the background color. This ... Read More

2K+ Views
In this article, we will learn to disable the maximize button of a JFrame in Java. When creating Swing GUIs in Java, we might occasionally want to prevent users from maximizing certain windows. Removing the maximize button will do the trick for dialog windows, tool windows, or any window where a fixed size needs to be kept. What is a JFrame? A JFrame is a class from javax. swing package and it can extend java.awt.frame class. It is a top-level window with a border and a title bar. A JFrame class has many methods that can be used to customize ... Read More

3K+ Views
In this article, we will learn to implement different borders using the BorderFactory in Java. While building graphical user interfaces (GUIs) with Java Swing, borders can be useful in structuring and managing various sections of our interface. To make it easier to develop several types of borders, Swing offers the BorderFactory class. What is a BorderFactory? The BorderFactory is a Factory class that provides different types of borders in Java BorderFactory, located in the javax.swing package, is a utility class containing static methods to create new Border objects. Because these methods internally manage border instances, you typically get reused border instances whenever ... Read More

1K+ Views
A JTextArea is a multi-line text component to display text or allow the user to enter the text and it will generate a CaretListener interface when we are trying to implement the functionality of the JTextArea component. A JTextArea class inherits the JTextComponent class in Java.In the below example, we can implement a JTextArea class with a user can select either word wrap or line wrap checkboxes using the ItemListener interface.Exampleimport javax.swing.*; import java.awt.*; import java.awt.event.*; public class JTextAreaTest { public static void main(String[] args ) { EventQueue.invokeLater(new Runnable() { @Override public void run() { ... Read More

3K+ Views
In this article, we will learn about the differences between a JScrollBar and a JScrollPane in Java. A JScrollBar is a component, and it doesn't handle its own events whereas a JScrollPane is a Container and it handles its own events and performs its own scrolling. A JScrollBar cannot have a JScrollPane whereas a JScrollPane can have a JScrollBar. JScrollBar The object of the JScrollBar class is used to add horizontal and vertical scrollbar which allow the user to select items between a specified minimum and maximum values. A JScrollBar class is an implementation of a scrollbar and inherits the ... Read More

174 Views
A JDialog is a subclass of Dialog class and it does not hold minimize and maximize buttons at the top right corner of the window. We can create two types of JDialog boxes.in JavaModal DialogNon-Modal DialogModal JDialogIn Java, When a modal dialog window is active, all the user inputs are directed to it and the other parts of the application are inaccessible until this model dialog is closed.Non-Modal JDialogIn Java, When a non-modal dialog window is active, the other parts of the application are still accessible as normal and inputs can be directed to them, while this non-modal dialog window doesn't need to be ... Read More

1K+ Views
In this article, we will learn about the implementation of a JToggleButton in Java. The JToggleButton is a basic Swing component in Java that is used to represent a two-state button, i.e., selected or unselected. It is therefore the best component to use when adding on/off or mode selection functionality to Java applications. JToggleButton A JToggleButton is an extension of AbstractButton, and it can be used to represent buttons that can be toggled ON and OFF. When JToggleButton is pressed for the first time, it remains pressed and it can be released only when it is pressed for the second ... Read More

5K+ Views
In this article, we will learn how to limit the number of characters inside a JTextField in Java. Whether you're creating a form for phone numbers, zip codes, or usernames, controlling the maximum number of characters is important for data validation. JTextField A JTextField is one of the most important Swing components that allows the user to an input text value in a single line format. We can restrict the number of characters that the user can enter into a JTextField can be achieved by using the PlainDocument class. PlainDocument Class PlainDocument is a subclass that extends the AbstractDocument, a ... Read More

3K+ Views
In Java, a JComboBox is a component that displays a drop-down list and gives users options that we can select one and only one item at a time whereas a JList shows multiple items (rows) to the user and also gives an option to let the user select multiple items. JComboBox A JComboBox can be editable or read-only. An ActionListener, ChangeListener, or ItemListener interface can be used to handle the user actions on a JComboBox. Syntax The following is the syntax for JComboBox initialization: String[] fruits = {"Apple", "Banana", "Orange", "Mango"}; JComboBox comboBox = new JComboBox(fruits); We can create a ... Read More