
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 7442 Articles for Java

39K+ Views
The layout managers are used to automatically decide the position and size of the added components. In the absence of a layout manager, the position and size of the components have to be set manually. The setBounds() method in Java is used in such a situation to set the position and size. To specify the position and size of the components manually, the layout manager of the frame can be null. The setBounds() Method The setBounds() is a method inherited from Java's AWT (Abstract Window Toolkit) and Swing libraries that enables manual positioning and sizing of GUI components. The setBounds() ... Read More

5K+ Views
In Java, the EventListener interface defines the methods that must be implemented by an event handler for a particular kind of event, whereas an Event Adapter class provides a default implementation of the EventListener interface. Java EventListener The EventListeners are the backbone of every component to handle the events. Every method of a particular EventListener will have a single parameter as an instance, which is a subclass of the EventObject class. An EventListener interface needs to be extended, and it will be defined in java.util package. Syntax The following is the syntax for EventListener declaration: public interface EventListener EventListener interfaces ... Read More

11K+ Views
In this article, we will learn about the importance of the Container class in Java. The Container class plays a vital role in creating graphical user interfaces (GUIs) and managing the layout of components. What is the Container Class? A Container class can be described as a special component that can hold a group of components. There are two types of Swing Containers they are top-level containers and low-level containers. Top-level containers are heavyweight containers such as JFrame, JApplet, JWindow, and JDialog. Low-level containers are lightweight containers such as JPanel. The most commonly used containers are JFrame, JPanel, and JWindow. ... Read More

211 Views
In this article, we will learn about the importance of the CardLayout class in Java. In Swing, we usually have to manage a set of views and panels in a single container. The CardLayout class provides you with a flexible and powerful method to complete this, allowing you to switch between various components, such as cards in a deck. What is CardLayout? CardLayout is a layout manager in the Java AWT package. It is different from the other layouts, where the other layout managers attempt to display all the components within the container at once, the CardLayout displays only one ... Read More

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

8K+ 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