
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

1K+ Views
In this article, we will learn to select one item at a time from a JCheckBox in Java. When creating Java Swing applications, you might have situations where you need checkboxes to behave like radio buttons, such that a box can be checked singly at any given time. JCheckBox A JCheckBox can extend JToggleButton, and it can be a small box that is either checked or unchecked. When we click on a JCheckBox, it changes from checked to unchecked or vice versa automatically. Syntax The following is the syntax for JCheckBox initialization: JCheckBox checkBox = new JCheckBox("Option"); A JCheckBox can ... Read More

339 Views
JTabbedPaneA JTabbedPane is a component can extend JComponent class and it can provide easy access to more than one panel.Each tab is associated with a single component that can be displayed when the tab is selected.A JTabbedPane can generate a ChangeListener interface when a tab is selected.The important methods of JTabbedPane are add(), addTab(), fireStateChanged(), createChangeListener(), setSelectedIndex(), getTabCount() and etc.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class JTabbedPaneTest extends JFrame implements ActionListener { JTabbedPane tabbedPane; int ntabs = 0; public JTabbedPaneTest() { getContentPane().setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(); ... Read More

2K+ Views
In this article, we will learn to implement right right-click menu using JPopupMenu in Java. A JPopupMenu appears anywhere on the screen when the right mouse button is clicked. JPopupMenu A JPopupMenu menu is a free-floating menu that is associated with an underlying component called the invoker. Most of the time, a popup menu is linked to a specific component to display context-sensitive choices. Syntax The following is the syntax for JPopupMenu initialization: JPopupMenu popup = new JPopupMenu(); In order to create a popup menu, we can use the JPopupMenu class., We can add the JMenuItem to the ... Read More

2K+ Views
In Java, a JTextPane is an extension of JEditorPane which provides word processing features like fonts, text styles, colors and etc. If we need to do heavy-duty text processing, we can use this class, whereas a JEditorPane supports display/editing of HTML and RTF content and can be extended by creating our own EditorKit. JTextPane A JTextPane is a subclass of JEditorPane. A JTextPane is used for a styled document with embedded images and components. A JTextPane is a text component that can be marked up with the attributes that are represented graphically and it can use a DefaultStyledDocument as the ... Read More

295 Views
The class which process the WindowEvent needs to be implemented this interface and an object of this class can be registered with a component by using addWindowListener() method.Methods of WindowListener InterfaceThe WindowListener interface defines 7 methods for handling window eventsvoid windowActivated(WindowEvent we) − Invoked when a window is activated.void windowDeactivated(WindowEvent we) − Invoked when a window is deactivated.void windowOpened(WindowEvent we) − Invoked when a window is opened.void windowClosed(WindowEvent we) − Invoked when a window is closed.void windowClosing(WindowEvent we) − Invoked when a window is closing.void windowIconified(WindowEvent we) − Invoked when a window minimized.void windowDeiconfied(WindowEvent we) − Invoked when a window is restored.Syntaxpublic ... Read More

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

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

197 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