Smita Kapse has Published 498 Articles

How to add empty border to JPanel in Java?

Smita Kapse

Smita Kapse

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

1K+ Views

To add empty border, use the createEmtyBorder() method. Let us first create a new JLabel −JLabel label; label = new JLabel("Label with empty border!");Now, set empty border using the setBorder() method −label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));The following is an example to add empty border to JPanel −Examplepackage my; import javax.swing.BorderFactory; ... Read More

How to set multidimensional array into JTable with Java?

Smita Kapse

Smita Kapse

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

834 Views

To set multidimensional array into a table, we need the values for rows and columns. Therefore, create a multidimensional array for rows −Integer[][] marks = {    { 70, 66, 76, 89, 67, 98 },    { 67, 89, 64, 78, 59, 78 },    { 68, 87, 71, 65, ... Read More

Implementing MongoDB $exists and $ne?

Smita Kapse

Smita Kapse

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

341 Views

The $exists is used to check whethre a filed exists, whereas $ne is for not equal condition. Let us first create a collection with documents −> db.existsDemo.insertOne({"Name":"Chris", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c3916d78f205348bc650") } > db.existsDemo.insertOne({"Name":"", "Age":null}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c39a6d78f205348bc651") } > db.existsDemo.insertOne({"Name":null, "Age":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7c3a66d78f205348bc652") } > db.existsDemo.insertOne({"Age":23}); ... Read More

Why are NULL pointers defined differently in C and C++?

Smita Kapse

Smita Kapse

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

216 Views

In C++, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0, like −int*p = 0;But in c, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0 ... Read More

When should I write the keyword 'inline' for a function/method in C++?

Smita Kapse

Smita Kapse

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

171 Views

In C++, the inline keyword is used in different places. To create inline variables, or inline namespace, and as well as to create inline methods or functions.C++ inline function is powerful concept that is commonly used with classes. If a function is inline, the compiler places a copy of the ... Read More

Aggregate a $slice to get an element in exact position from a nested array in MongoDB?

Smita Kapse

Smita Kapse

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

204 Views

You can use aggregate framework for this. Let us first create a collection with documents −>db.exactPositionDemo.insertOne({"StudentName":"John", "StudentScores":[78, 98, 56, 45, 89]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd29a1c345990cee87fd883") }Following is the query to display all documents from a collection with the help of find() method −> db.exactPositionDemo.find().pretty();This will ... Read More

Java Program to set minor tick marks in a JSlider every 10 units

Smita Kapse

Smita Kapse

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

295 Views

Minor Tick marks is the number passed in representing the distance between each minor tick mark. For example, a slider with range from 0 to 70 and minor tick spacing 10, would give minor ticks next to the following values: 0, 10, 20, 30, 40, 50, 60, 70.To set minor ... Read More

Floating point comparison in C++

Smita Kapse

Smita Kapse

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

14K+ Views

Here we will see how to compare two floating point data using C++. The floating point comparison is not similar to the integer comparison.To compare two floating point values, we have to consider the precision in to the comparison. For example, if two numbers are 3.1428 and 3.1415, then they ... Read More

How to create android Notification intent to clear it self?

Smita Kapse

Smita Kapse

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

364 Views

This example demonstrate about How to create a local Notifications in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 ... Read More

Proper stack and heap usage in C++?

Smita Kapse

Smita Kapse

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

703 Views

The stack − All variables declared inside the function will take up memory from the stack. So, any local variable inside a function lives on the stack.The heap − This is unused memory of the program and can be used to allocate the memory dynamically when program runs. So If ... Read More

Advertisements