Karthikeya Boyini has Published 2193 Articles

How to set minimum size limit for a JFrame in Java

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

Use the setMinimumSize() method to set the minimum size limit for a JFrame −JFrame frame = new JFrame(); frame.setMinimumSize(new Dimension(500, 300));The following is an example to set minimum size limit for a JFrame −Exampleimport java.awt.Color; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] ... Read More

How to create modeless and model JDialog in Java?

karthikeya Boyini

karthikeya Boyini

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

580 Views

MODELESS TypeThe following is an example to set JDialog with Modality type MODELESS −Exampleimport java.awt.Cursor; import java.awt.Dialog.ModalityType; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();     ... Read More

Generate random numbers following a normal distribution in C/C++

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

Here we will see how to generate random numbers, which are following in a normal distribution. For the normal random, the formula is like below.𝑧 = √−2 ln 𝑥1 cos (2𝜋𝑥2)Here x1 and x2 are chosen randomly.Example#include #include #include #include using namespace std; double rand_gen() { ... Read More

How to get time in milliseconds using C++ on Linux?

karthikeya Boyini

karthikeya Boyini

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

5K+ Views

Here we will see how to get time (the elapsed time for the program or any other kind of time).Here we are using linux library for C++. There is a structure called timeval. This timeval stores the time in seconds, milliseconds. We can create two time for start and end, ... Read More

Auto insert values into a MySQL table in a range?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

For this, you can create a stored procedure. Let us first create a table.mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.55 sec)Following is the query to create a stored procedure to auto insert values to a table from ... Read More

How to output colored text to a Linux terminal?

karthikeya Boyini

karthikeya Boyini

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

8K+ Views

Here we will see how to print some lines into the linux terminal with some color. Here we are doing anything special into C++ code. We are just using some linux terminal commands to do this. The command for this kind of output is like below.\033[1;31m Sample Text \033[0mThere are ... Read More

Determine what a MySQL DB’s charset is set to

karthikeya Boyini

karthikeya Boyini

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

142 Views

Let’s say we are creating a database “web” −mysql> SHOW CREATE DATABASE web;This will produce the following output displaying the default charset as well −+----------+-----------------------------------------------------------------------------------------+ | Database | Create Database                                         ... Read More

Averaging a total from a Score column in MySQL with the count of distinct ids?

karthikeya Boyini

karthikeya Boyini

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

86 Views

You can use DISTINCT along with COUNT(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Score int    -> ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable ... Read More

How can I clear console using C++?

karthikeya Boyini

karthikeya Boyini

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

12K+ Views

We can clear the console using C++ code. To do this we have to execute some system commands. In Linux systems, the POSIX is used. We can call system() function to execute system command. For clearing the console in linux, we can use “clear” command. This will be passed inside ... Read More

How to create a high resolution timer with C++ and Linux?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To create high resolution timer we can use the chrono library. This library has high resolution clock. This can count in nanoseconds.In this program we will see the execution time in nanoseconds. We will take the time value at first, then another time value at the last, then find the ... Read More

Advertisements