Smita Kapse has Published 558 Articles

Send a notification when the Android app is closed

Smita Kapse

Smita Kapse

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

3K+ Views

This example demonstrate about How to Send a notification when the Android app is closedStep 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.   ... Read More

Find and replace NumberLong type field in MongoDB?

Smita Kapse

Smita Kapse

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

362 Views

Use $set operator along with update() for this. Let us first create a collection with documents. Here we have set one field as NumberLong −> db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c960b64f4b851c3a13b6") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(110)}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd2c966b64f4b851c3a13b7") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); ... Read More

Java Program to center a JLabel in a JPanel with LayoutManager

Smita Kapse

Smita Kapse

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

2K+ Views

Here, we are using the LayoutManager GridBagLayout to center the components. We have two components here including a label and we have set the layout as GridBagLayout −JLabel label = new JLabel("Name (Centered Label): "); JTextArea text = new JTextArea(); text.setText("Add name here..."); panel.setLayout(new GridBagLayout());The following is an example to ... Read More

What is the MongoDB Capped Collection maximum allowable size?

Smita Kapse

Smita Kapse

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

181 Views

It is up to you how much space you want. You need to use the parameter size to set. Use below syntax −db.createCollection(‘yourCollectionName’, capped=true, size=yourValue);Let us implement the above syntax in order to allow size for a capped collection −> db.createCollection('cappedCollectionMaximumSize', capped=true, size=1948475757574646); { "ok" : 1 }Let us check ... Read More

Can MongoDB find() function display avoiding _id?

Smita Kapse

Smita Kapse

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

98 Views

Yes, we can avoid the _id, using the following syntax in MongoDB −db.yourCollectionName.find({}, { _id:0});Let us first create a collection with documents:>> db.excludeIdDemo.insertOne({"CustomerName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f62c1a844af18acdffb9") } > db.excludeIdDemo.insertOne({"CustomerName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f6311a844af18acdffba") } > db.excludeIdDemo.insertOne({"CustomerName":"Mike"}); {    "acknowledged" ... Read More

How to change the minimum value of a JSlider in Java?

Smita Kapse

Smita Kapse

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

165 Views

To change the minimum value of a slider in Java, use the setMinimum() method wherein set the minimum value.Let’s say the following is our slider in Java −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true);Now, set the minimum value −slider.setMinimum(10);The following is an example to change ... Read More

Interesting Facts about C Programming

Smita Kapse

Smita Kapse

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

312 Views

Here we will see some interesting facts about C programming. These are like below.Sometimes the case labels of some switch statement can be placed inside if-else statement.Example#include main() {    int x = 2, y = 2;    switch(x) {       case 1:         ... Read More

How can I update all elements in an array with a prefix string?

Smita Kapse

Smita Kapse

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

383 Views

To update all elements in an array with a prefix string, use forEach(). Let us first create a collection with documents −> db.replaceAllElementsWithPrefixDemo.insertOne(    {       "StudentNames" : [          "John",          "Carol"       ]    } ); {   ... Read More

Java Program to set Horizontal Alignment of content in a JTextField

Smita Kapse

Smita Kapse

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

2K+ Views

The content in the JTextFile is by default left aligned, but you can change it using the setHorizontalAlignment() method. Let’s say the following is our JTextField −JTextField emailId = new JTextField(20);Now, we will set the horizontal alignment and set the alignment to the right for the JTextPane −emailId.setHorizontalAlignment(JTextField.RIGHT);The following is ... Read More

pthread_equal() in C

Smita Kapse

Smita Kapse

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

184 Views

The pthread_equal() function is used to check whether two threads are equal or not. This returns 0 or non-zero value. For equal threads, it will return non-zero, otherwise it returns 0. The syntax of this function is like below −int pthread_equal (pthread_t th1, pthread_t th2);Now let us see the pthread_equal() ... Read More

Advertisements