Arjun Thakur has Published 1109 Articles

How to limit the amount of characters returned from a field in a MongoDB query?

Arjun Thakur

Arjun Thakur

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

109 Views

For this, use MongoDB $substr. Let us first create a collection with documents −> dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MongoDB is No SQL database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf23013b64a577be5a2bc0e") } > dblimitTheNumberOfCharactersDemoinsertOne({"Title":"MySQL is a relational database"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2302db64a577be5a2bc0f") } Following is the query ... Read More

How to check if two nodes are equal in a JTree with Java?

Arjun Thakur

Arjun Thakur

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

625 Views

To check if two nodes are equal, use the equals() method. Here, we are checking that node1 and node2 are equal or not.node1.equals(node2)The following is an example to check if two nodes are equal in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {   ... Read More

How to enable the display of hidden files in a JFileChooser in Java?

Arjun Thakur

Arjun Thakur

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

258 Views

Set the following to FALSE to enable the display of hidden files −JFileChooser file = new JFileChooser(); file.setFileHidingEnabled(false);The following is an example to enable the display of hidden files in a JFileChooser −Examplepackage my; import javax.swing.JFileChooser; public class SwingDemo {    public static void main(String[] args) {       ... Read More

HTML currentTarget Event Property

Arjun Thakur

Arjun Thakur

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

106 Views

The currentTarget event property in HTML is used to get the element whose event listeners triggered the event.Following is the syntax −event.currentTargetLet us now see an example to implement the currentTarget event property −Example Live Demo Get the element Click on this line to generate an alert box displaying ... Read More

How to turn Android device screen on and off programmatically?

Arjun Thakur

Arjun Thakur

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

3K+ Views

This example demonstrate about How to turn Android device screen on and off programmatically.Step 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

How to lock the Android device programmatically?

Arjun Thakur

Arjun Thakur

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

3K+ Views

This example demonstrate about How to lock the Android device programmatically.Step 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

How to align views at the bottom of the screen in Android?

Arjun Thakur

Arjun Thakur

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

5K+ Views

This example demonstrate about How to align views at the bottom of the screen in Android.Step 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.java ... Read More

How to make an Android device vibrate programmatically?

Arjun Thakur

Arjun Thakur

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

574 Views

This example demonstrate about How to make an Android device vibrate programmatically.Step 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.java     Step 3 ... Read More

Add data to existing data in a MySQL Database?

Arjun Thakur

Arjun Thakur

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

672 Views

You can use CONCAT() function for this. Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(100)    ); Query OK, 0 rows affected (0.43 sec)Insert records in the table using insert command −mysql> insert into DemoTable(UserName) ... Read More

How to use AutoCompleteTextView in Android App?

Arjun Thakur

Arjun Thakur

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

137 Views

This example demonstrate about How to use AutoCompleteTextView in Android App.Step 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.java     Step 3 − ... Read More

Advertisements