
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

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

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

672 Views
JWindow is a Swing component that is used to create a splash screen easily as splash screen as it displays a screen without a title bar or window management buttons. In this article, we will learn to implement a splash screen using JWindow in Java. What is a JWindow? A JWindow is a container that can be displayed anywhere on the user's desktop. It does not have the title bar, window management buttons, etc, like a JFrame. The JWindow contains a JRootPane as its only child class. The contentPane can be the parent of any children of the JWindow. Like a ... Read More