Samual Sam has Published 2492 Articles

Java Program to create a vertical ProgressBar

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

271 Views

To create a vertical ProgressBar, use the following property −JProgressBar.VERTICALSet it like this −JProgressBar progressBar = new JProgressBar(JProgressBar.VERTICAL, 0, 1000);The following is an example to create a vertical ProgressBar −Examplepackage my; import java.awt.Color; import javax.swing.*; public class SwingDemo extends JFrame {    JProgressBar progressBar;    int i = 0;   ... Read More

How to change JFrame background color in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

19K+ Views

At first, create a JFrame −JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(550, 300));Now, change the background color of the JFrame −frame.getContentPane().setBackground(Color.BLUE);The following is an example to change JFrame background color −Exampleimport java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {     ... Read More

How to close JFrame on the click of a Button in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

11K+ Views

Set frame.dispose() on the click of a button to close JFrame. At first create a button and frame −JFrame frame = new JFrame(); JButton button = new JButton("Click to Close!");Now, close the JFrame on the click of the above button with Action Listener −button.addActionListener(e -> {    frame.dispose(); });The following ... Read More

How to count set bits in a floating point number in C?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

408 Views

In this problem, one floating point value is given. We have to find number of set bits in the binary representation of it.For example, if a floating point number is 0.15625, so there are six set bits. A typical C compiler used single precision floating point representation. So it will ... Read More

How to write a running C code without main()?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

7K+ Views

Here we will see, one program can be written without main or not? The answer is yes. We can write program, that has no main() function.In many places, we have seen that the main() is the entry point of a program execution. Just from the programmers perspective this is true. ... Read More

Use of bool in C

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

2K+ Views

In C there is no predefined datatype as bool. We can create bool using enum. One enum will be created as bool, then put the false, and true as the element of the enum. The false will be at the first position, so it will hold 0, and true will ... Read More

C++ Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

123 Views

This is a C++ Program to find k numbers closest to Median of S, where S is a set of n numbers.AlgorithmsBegin    function partition() for partitioning the array on the basis of values at high as pivot value:    Arguments:       a[]=an array.       l=low ... Read More

C++ Program to Find the Mode in a Data Set

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

454 Views

This is a C++ program to find the Mode in a data set.AlgorithmsBegin    function insertinset() to insert data in the set.    Create newnode and temp(t) node.    Node to be inserted in the list using newnode.    If head is null then       assign new node ... Read More

C++ Program to Implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for Elements From 1 to N

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:26

90 Views

This is a C++ program to implement the Alexander Bogomolny’s UnOrdered Permutation Algorithm for elements from 1 to NAlgorithmsBegin    function AlexanderBogomolny() to implement the Algorithms    Arguments:       Val[] = an array       N = number of elements taken as input.       K ... Read More

How to set default date time as system date time in MySQL?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

425 Views

You can use CURRENT_TIMESTAMP to set system date time. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientFirstName varchar(20),    ClientLastName varchar(20),    ClientAge int ); Query OK, 0 rows affected (0.66 sec)Following is the query to set default ... Read More

Advertisements