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
Programming Articles - Page 2519 of 3366
4K+ Views
A JTable is a subclass of JComponent class 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 change the background and foreground color for each column of a JTable by customizing the DefaultTableCellRenderer class and it has only one method getTableCellRendererComponent() to implement it.Exampleimport java.awt.*; import javax.swing.*; import javax.swing.table.*; public class JTableColumnColorTest extends JFrame { private JTable table; private TableColumn tColumn; public JTableColumnColorTest() { setTitle("JTableColumnColor Test"); table = ... Read More
383 Views
In this article, we will learn to change the background and foreground color of a JTooltip. We will be using UIManager.put(), we customize the tooltip for a JLabel by setting a white background and green text, which will improve the appearance of the default tooltip. What is a JToolTip? A JToolTip is a subclass of the JComponent class, and we can create a tooltip for any Java component by using the setToolTipText() method. It can be used to set up a tooltip for the component. The important methods of a JToolTip class are getAccessibleContext(), getComponent(), paramString(), and updateUI(). How to ... Read More
4K+ Views
In this article, we will learn to detect an event when the mouse moves over any component in Java. While building applications with Swing, detecting when the mouse enters or exits a component enables you to create responsive UIs with visual feedback. MouseListener We can implement a MouseListener interface when the mouse is stable while handling the mouse event. A MouseEvent is fired when we can 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. ... Read More
4K+ Views
Here, as per the given problem pattern needs to be displayed using recursive approach.Recursive function is the one that calls itself n number of times. There can be ‘n’ number of recursive function in a program. The problem working with recursive function is their complexity.AlgorithmSTART Step 1 -> function int printpattern(int n) If n>0 Printpattern(n-1) Print * End IF End Step 2 -> function int pattern(int n) If n>0 pattern(n-1) End IF Printpattern(n) Print End STOPExample#include int printpattern(int n) { if(n>0) { ... Read More
126 Views
Given with equation program must find the value of ‘a’ where a+b Declare start variables b=10, x=9, n=40 and flag=0, divisible Step 2 -> Loop For divisible = (b / x + 1 ) * x and divisible = 1 Print divisible-1 Set flag=1 End END STOPExample#include int main(int argc, char const *argv[]) { int b=10, x=9, n=40, flag = 0; int divisible; for (divisible = (b / x + 1 ) * x ; divisible = 1) { printf("%d ", divisible - b ); flag = 1; } } return 0; }Outputif we run above program then it will generate following output8 17 26
258 Views
Given with array of let’s say k elements the program must find the n smallest elements amongst them in their appearing order.Input : arr[] = {1, 2, 4, 3, 6, 7, 8}, k=3 Ouput : 1, 2, 3 Input k is 3 it means 3 shortest elements among the set needs to be displayed in original order like 1 than 2 and than 3AlgorithmSTART Step 1 -> start variables as int i, max, pos, j, k=4 and size for array size Step 2 -> Loop For i=k and i=0 and j-- If arr[j]>max ... Read More
414 Views
Newman-Conway Sequence is used for generating following integer sequence.1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12Formula used for generating Newman-Conway sequence for n numbers is −P(n) = P(P(n - 1)) + P(n - P(n - 1)) Where, p(1) =p(2) =1AlgorithmSTART Step 1 -> Input variable n(e.g. 20) Step 2 -> start variables as i, p[n+1], p[1]=1, p[2]=1 Step 3 -> Loop For i=3 and i End Loop For STOPExample#include int main() { int n = 20,i; int p[n + 1]; p[1] = 1; p[2] = 1; printf("Newman-Conway Sequence is :"); printf("%d %d ",p[1],p[2]); for (i = 3; i
347 Views
Given with two numbers x and y the output should contain their kth common factor.Input: x=9 y=18 k=1 Output : k common factor = 2 Factors of 9 : 1, 3, 9 Factors of 18 : 1, 2, 3, 6, 9, 18 Greatest Common Factor : 9AlgorithmSTART Step 1 -: take input as x and y lets say 3 and 21 and k as 1 Step 2 -: declare start variables as int i,num,count=1 Step 3 -: IF x
13K+ Views
There are different ways by which system day, date and time can be printed in Human Readable Form.First wayUsing time() − It is used to find the current calendar time and have arithmetic data type that store timelocaltime() − It is used to fill the structure with date and timeasctime() − It converts Local time into Human Readable FormatDay Month Date hour:month:second YearExample#include #include // used to work with date and time using namespace std; int main() { time_t t; // t passed as argument in function time() struct tm * tt; // decalring variable for localtime() ... Read More
221 Views
GCDGCD stands for Greatest Common Divisor of two or more integers excluding 0Like, to find the greatest common divisor of 48 and 18048 = 2 × 2 × 2 × 2 × 3180 = 2 × 2 × 3 × 3 × 5Greatest common divisor = 2 × 2 × 3 = 12.In the given problem, N lines should be printed with elements have GCD as specifiedInput : N=2 GCD=2 Ouput : 2-4-6-10 14-16-18-22AlgorithmSTART Step 1 -> take input n(e.g. 2) and k(e.g. 2) as int values and i Step 2-> Loop For i to 0 and i end loop ... Read More