
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 111 Articles for AWT

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

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

782 Views
A SwingWorker class enables us to perform an asynchronous task in a worker thread (such as a long-running task) then update Swing components from the Event Dispatch Thread (EDT) based on the task results. It was introduced in Java 1.6 Version.SwingWorker classThe java.swing.SwingWorker class is a task worker, which performs time-consuming tasks in the background.A SwingWorker instance interacts with 3 threads, Current thread, the Worker thread, and the Event Dispatch thread(EDT).The Current thread calls the execute() method to kick off the task to the background and returns immediately.The Worker thread executes our own version of the doInBackground() method continuously in the background.The Event Dispatch Thread (EDT) wakes up from time to ... Read More

1K+ Views
In this article, we will learn about the differences between a MouseListener and a MouseMotionListener in Java. We can implement a MouseListener interface when the mouse is stable while handling the mouse event, whereas we can implement a MouseMotionListener interface when the mouse is in motion while handling the mouse event. Mouse Listener A MouseListener is fired when we press, release or click (press followed by release) a mouse button (left or right button) at the source object or position the mouse pointer at (enter) and away (exit) from the source object. Abstract Methods A MouseListener interface declares the following five ... Read More