
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 9150 Articles for Object Oriented Programming

486 Views
A JComboBox is a Swing component that has a built-in left-click menu. In this article, we will learn how to show a popup menu when the user right-clicks on a JComboBox in Java. What is a JComboBox? A JComboBox is a subclass of the JComponent class that displays a drop-down list and gives users options that they can select only one item at a time. A JComboBox can be editable or read-only. The getSelectedItem() Method A getSelectedItem() method can be used to get the selected or entered item from a combo box. What is a Popup Menu? A popup menu is ... Read More

480 Views
In this article, we will learn to set a background color for JSplitPane in Java. JSplitPane is a Swing component that divides two (or more) components with a resizable divider. By default, JSplitPane does not directly support background color changes due to its complex structure. What is a JSplitPane? A JSplitPane is a subclass of the JComponent class that allows us to arrange two components side by side horizontally or vertically in a single pane. The display areas of both components can also be adjusted at runtime by the user. Syntax The following is the syntax for a JSplitPane initialization: JSplitPane ... Read More

3K+ Views
A JTable is a subclass of JComponent for displaying complex data structures. A JTable component can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener, RowSorterListener interfaces. We can implement the search functionality of a JTable by input a string in the JTextField, it can search for a string available in a JTable. If the string matches it can only display the corresponding value in a JTable. We can use the DocumentListener interface of a JTextField to implement it.Exampleimport java.awt.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public ... Read More

521 Views
In this article, we will learn how to hide the left/right pane of a JSplitPane programmatically in Java. JSplitPane is a simple Swing component in GUI programming that allows hiding one side of the split pane, resulting in a collapsible panel look. JSplitPane A JSplitPane is a subclass of the JComponent class that allows us to arrange two components side by side horizontally or vertically in a single pane. The display areas of both components can also be adjusted at runtime by the user. The important methods of JSplitPane are remove(), removeAll(), resetToPreferredSizes(), and setDividerLocation(). A JSplitPane can generate a ... Read More

7K+ Views
First, let us understand how attributes work in JavaScript. Any element's attributes can be changed with JavaScript. The attributes property stores them, and invoking it gives you direct access to them. If we target an element with a class, the class will also appear as an attribute, and we can actually utilize these attribute methods to change classes if we so choose. Now, keep in mind that while we have designated the properties and methods for classes, you can also utilize all of these characteristics to manipulate classes in any element if necessary. href attributes in JavaScript In the href ... Read More

8K+ Views
A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface. We can add or insert a JButton to JTable cell by customizing the code either in DefaultTableModel or AbstractTableModel and we can also customize the code by implementing TableCellRenderer interface and need to override getTableCellRendererComponent() method.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class JTableButtonTest extends JFrame { private JTable table; private JScrollPane scrollPane; public JTableButtonTest() { ... Read More

2K+ Views
In this article, we will learn to read an input value from a JTextField and add it to a JList in Java. The Swing's two commonly used components are JTextField for text input and JList for displaying a list of items for building graphical user interfaces. JList A JList is a subclass of the JComponent class that allows the user to choose either a single selection or multiple selections. The JList class itself does not support a scrollbar. In order to add a scrollbar, we have to use the JScrollPane class together with the JList class. The JScrollPane then manages ... Read More

2K+ Views
The spread operator, which was first introduced in ES6, is used to unpack the elements of an iterable like an array. Cloning and merging the array is simple thanks to the spread operator. The spread operator could not be used with objects when it was first introduced in ES6. The spread operator was eventually extended to objects in ES2018. You'll learn how to use the JavaScript object spread (...) to clone an object or merge two objects into one in this article. In areas where 0+ arguments are expected, the spread operator allows an iterable to extend. This is most ... Read More

4K+ Views
While developing Java Swing applications, you may have cases when you need to modify the space around JButtons to develop attractive applications. In this article, we will learn to set the margin of a JButton in Java. What is a JButton? A JButton is a subclass of AbstractButton, and it can be used for adding platform-independent buttons to a Java Swing application. A Button can generate an ActionListener interface when the button is pressed or clicked, it can also generate the MouseListener and KeyListener interfaces. Syntax The following is the syntax for JButton initialization: JButton button = new JButton("Button"); We ... Read More

5K+ Views
In this article, we will learn to minimize/maximize a JFrame programmatically in Java. In Swing, programmers often need to resize the window as needed. For example, they can shrink the window when carrying out background tasks or expand the window size for a better full-screen experience. What is a JFrame? A JFrame class is a subclass of Frame class and the components added to a frame are referred to as its contents, these are managed by the contentPane. A JFrame contains a window with title, border, (optional) menu bar and user-specific components. By default, we can minimize a JFrame by ... Read More