Smita Kapse has Published 558 Articles

Show android notification every five minutes?

Smita Kapse

Smita Kapse

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

926 Views

This example demonstrate about How to Show android notification every five minutesStep 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

How to rename a username in MongoDB?

Smita Kapse

Smita Kapse

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

1K+ Views

To rename a user, you need to use update() and $set to set the new username. Following is the syntax −db.system.users.update({"user":"yourOldUserName"}, {$set:{"user":"yourNewUserName"}});Firstly, display all the users from the MongoDB database −> use admin; switched to db admin > db.getUsers();This will produce the following output −[    {     ... Read More

I want to create a new field in an already created document. How can this be done using MongoDB query?

Smita Kapse

Smita Kapse

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

53 Views

Use $addToSet to create a new field in MongoDB. Let us first create a collection with documents −> db.createFieldDemo.insertOne({"StudentFirstName":"John", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd99e28b50a6c6dd317ad95") } > db.createFieldDemo.insertOne({"StudentFirstName":"Larry", "StudentAge":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd99e2fb50a6c6dd317ad96") } > db.createFieldDemo.insertOne({"StudentFirstName":"Chris", "StudentAge":22}); {    "acknowledged" : ... Read More

How to automatically resize a JTree in Java

Smita Kapse

Smita Kapse

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

194 Views

To automatically resize a JTree, use the setVisibleRowCount() method in Java. At first, create a node in the tree −DefaultMutableTreeNode node = new DefaultMutableTreeNode("Project");Now, add nodes to the node created above −DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("App"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("WebApp"); node.add(node1); node.add(node2); node.add(node3);Now, create ... Read More

Incompatibilities between C and C++

Smita Kapse

Smita Kapse

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

110 Views

Here we will see some incompatibilities between C and C++. Some C codes that can be compiled using C compiler, but does not compile in C++ compiler. And also returns error.We can define function using a syntax, that optionally specify the argument types after the argument list.Example#include void my_function(x, y)int ... Read More

Disallow resizing a column by dragging between headers in a JTable Component with Java

Smita Kapse

Smita Kapse

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

82 Views

Let us first create a table with rows and columns −String data[][] = { {"Australia", "5", "1"},    {"US", "10", "2"},    {"Canada", "9", "3"},    {"India", "7", "4"},    {"Poland", "2", "5"},    {"SriLanka", "5", "6"} }; String col [] = {"Team", "Selected Players", "Rank"}; DefaultTableModel tableModel = new ... Read More

Particular field as result in MongoDB?

Smita Kapse

Smita Kapse

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

92 Views

To get particular field as a result in MongoDB, you can use findOne(). Following is the syntax −db.yourCollectionName.findOne({"yourFieldName1":yourValue}, {yourFieldName2:1});Let us first create a collection with documents −> db.particularFieldDemo.insertOne({"EmployeeName":"John Smith", "EmployeeAge":26, "EmployeeTechnology":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd9b4abb50a6c6dd317ada2") } > db.particularFieldDemo.insertOne({"EmployeeName":"Chris Brown", "EmployeeAge":28, "EmployeeTechnology":"Java"}); {    "acknowledged" : ... Read More

How to allow contigous selection of nodes in a JTree?

Smita Kapse

Smita Kapse

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

92 Views

Contigous selection means sharing borders like selecting siblings of a node in a JTree. To allow contiguous selection of nodes, set the selection mode to CONTIGUOUS_TREE_SELECTION −tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);The following is an example to allow contigous selection of nodes in a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeSelectionModel; public class SwingDemo {    public static void main(String[] args) throws Exception {     ... Read More

What is data type of FILE in C?

Smita Kapse

Smita Kapse

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

3K+ Views

In C we have used Files. To handle files, we use the pointer of type FILE. So the FILE is a datatype. This is called the Opaque datatype. So its implementation is hidden. The definition of the FILE is system specific. This is the definition of FILE in Ubuntu System ... Read More

How to unset a variable in MongoDB shell?

Smita Kapse

Smita Kapse

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

428 Views

Use delete operator to unset variable in MongoDB shell. Following is the syntax −delete yourVariableName;Let us now implement the above syntax in order to unset variable in MongoDB shell. First, print the variable name −> customerDetail;This will produce the following output −2019-05-08T22:29:17.361+0530 E QUERY [js] ReferenceError: customerDetail is not defined ... Read More

Advertisements