
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

601 Views
To find the angles of a triangle we can use sin/cosine rules according to cosine rule −cos A = (b^2 + c^2 - a^2)/2bcwhere A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides a, b, c given are −angleAtA = acos((b^2 + c^2 - a^2)/(2bc)) angleAtB = acos((a^2 + c^2 - b^2)/(2ac)) angleAtC = acos((a^2 + b^2 - c^2)/(2ab))

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

301 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

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

1K+ Views
_.union()_.Union() method belongs to underscore.js a library of javascript. The _.union() function is used to take n number of arrays and return a new array with the unique terms in all those arrays (union of all array). It scrutinizes each and every value of the arrays and pushes out unique values into another array.syntax_.union( array1, array2, .... );ExampleIn the following example, _.union() is used to get an array of unique elements.Live Demo document.write(_.union([1, 2, 9, 40], ... Read More

209 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