
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

10K+ Views
The JOptionPane is a subclass of the JComponent class, which includes static methods for creating and customizing modal dialog boxes using a simple code. The JOptionPane is used instead of JDialog to minimize the complexity of the code. The JOptionPane displays the dialog boxes with one of the four standard icons (question, information, warning, and error) or the custom icons specified by the user. Types of Dialogue Boxes in JOptionPane The JOptionPane class is used to display four types of dialog boxes: MessageDialog ConfirmDialog InputDialog ... Read More

2K+ Views
In Java, after swing components displayed on the screen, they can be operated by only one thread called Event Handling Thread. We can write our code in a separate block and can give this block reference to Event Handling thread. The SwingUtilities class has two important static methods, invokeAndWait() and invokeLater() to use to put references to blocks of code onto the event queue.Syntaxpublic static void invokeAndWait(Runnable doRun) throws InterruptedException, InvocationTargetException public static void invokeLater(Runnable doRun)The parameter doRun is a reference to an instance of Runnable interface. In this case, the Runnable interface will not be passed to the constructor of a Thread. The Runnable interface is simply ... Read More

15K+ Views
In this article, we will learn to make a JTextField accept only numbers in Java. By default, a JTextField can allow numbers, characters, and special characters. Validating user input that is typed into a JTextField can be difficult, especially if the input string must be converted to a numeric value such as an int. Different Approaches The following are the two different approaches for making a JTextField accept only numbers in Java: Using a KeyListener Using DocumentFilter Using a KeyListener The KeyListener interface handles keyboard events, making it straightforward to ... Read More

3K+ Views
Java Swing is a set of APIs that provides a graphical user interface (GUI) for the java programs. The Java Swing was developed based on earlier APIs called Abstract Windows Toolkit (AWT). The Java Swing provides richer and more sophisticated GUI components than AWT. The GUI components are ranging from a simple level to complex tree and table. The Java Swing provides the pluggable look and feels to allow look and feel of Java programs independent from the underlying platform.Features of Java SwingThe Java Swing is platform independent and follows the MVC (Model View and Controller) framework.Pluggable look and feel − The Java ... Read More

3K+ Views
Both JRadioButton and JCheckBox components can extend the JToggleButton class in Java, the main difference is that JRadioButton is a group of buttons in which only one button can be selected at a time, whereas JCheckBox is a group of checkboxes in which multiple items can be selected at a time. JRadioButton A JRadioButton is a component that represents an item with a state selected or unselected. Usually, a group of radio buttons is created to provide options to the user, but only one option can be selected at a time. JRadioButton will generate an ActionListener, ChangeListener, and ItemListener interfaces. Instantiating JRadioButton: JRadioButton Radio_Name = new JRadioButton(); ... Read More

5K+ Views
The GUI in Java processes the interactions with users via mouse, keyboard, and various user controls such as buttons, checkboxes, text fields, etc., as events. These events are to be handled properly to implement Java as an Event-Driven Programming. What is Event Handling? Event handling refers to the mechanism that controls events and determines the actions taken when an event occurs. This mechanism includes code known as an event handler, which is executed in response to an event. Components in Event Handling The following are the three main components of event handling in Java: Events ... Read More

5K+ Views
The main difference between JTextField and JTextArea in Java is that a JTextField allows entering a single line of text in a GUI application while the JTextArea allows entering multiple lines of text in a GUI application. JTextField The following are the key characteristics of JTextField in Java: A JTextFeld is one of the most important components that allow the user to an input text value in a single line format. A JTextField will generate an ActionListener interface when we trying to enter some input inside it. The JTextComponent is a superclass of JTextField that provides a common set ... Read More

2K+ Views
JFrameThe components added to the frame are referred to as its contents, these are managed by the contentPane. To add a component to a JFrame, we must use its contentPane instead.A JFrame contains a window with title, border, (optional) menu bar and user-specified components.A JFrame can be moved, resized, iconified and it is not a subclass of JComponent.By default, JFrame is displayed in the upper-left corner of the screen. To display a frame at a specified location, we can use the setLocation(x, y) method in the JFrame class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class JFrameDemo { public static void main(String s[]) { ... Read More

8K+ Views
In Java, a GridLayout puts all the components in a rectangular grid and is divided into equal-sized rectangles, and each component is placed inside a rectangle whereas GridBagLayout is a flexible layout manager that aligns the components vertically and horizontally without requiring that the components be of the same size. Java GridLayout A GridLayout arranges the components in a rectangular grid. It arranges components in the cells, and each cell has the same size. Components are placed in columns and rows. GridLayout(int rows, int columns) takes two parameters that are a column and a row. Syntax The following is the ... Read More

2K+ Views
No, Java Swing components are not thread-safe in Java. This means that whenever Swing components should be accessed or changed, it is done mostly by using a single thread, the EDT. Why Swing Components are not thread-safe One of the main reasons Java Swing is not thread-safe is to simplify the task of extending its components. Another reason for that Java Swing is not thread-safe due to the overhead involved in obtaining and releasing locks and restoring the state. Below are some methods given by Swing for safe operation with its UI: SwingUtilities.invokeLater(): In ... Read More