Articles on Trending Technologies

Technical articles with clear explanations and examples

Android NotificationBuilder Example

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 191 Views

This example demonstrate about Android NotificationBuilder.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.     Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.os.Bundle ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ;    private final static String default_notification_channel_id = "default" ;    @Override    protected void ...

Read More

Add a field to an embedded document in an array in MongoDB?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 544 Views

You can use update() along with $ operator for this. Let us first create a collection with documents −> db.addAFieldDemo.insertOne( ...   { ... ...      "ClientName" : "Larry", ...      "ClientCountryName" : "US", ...      "ClientOtherDetails" : [ ...         { ...            "ClientProjectName":"Online Banking System" ...         } ...      ] ...   } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd44bdc2cba06f46efe9ee8") }Following is the query to display all documents from a collection with the help of find() method −>  db.addAFieldDemo.find().pretty();This ...

Read More

How to get the Tab Size of a JTextArea in Java?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 439 Views

To get the tab size from a JTextArea, you can use the getTabSize() method −textArea.getTabSize();We will assign it to int variable and display the size in the Console −int size = textArea.getTabSize(); System.out.println("Tab Size = "+size);The following is an example to set the tab size of a JTextArea −Examplepackage my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo {    SwingDemo() {       JFrame frame = new JFrame();       JTextArea textArea = new JTextArea("This is demo text.");       int size = textArea.getTabSize();       System.out.println("Tab Size = "+size);       frame.add(textArea);     ...

Read More

How can I update a field in a MySQL database table by adding a value in the second table with a value from the first table?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 157 Views

Let us first create a table −mysql> create table DemoTable1    (    value int    ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+-------+ | value | +-------+ | 10 | +-------+ 1 row in set (0.00 sec)Following is the query to create second table −mysql> create table DemoTable2    (    value1 int    ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table ...

Read More

How do I check to see if a column name exists in a CachedRowSet in JDBC?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 3K+ Views

CachedRowSet interface does not provide any methods to determine whether a particular column exists.Therefore, to find whether a RowSet contains a specific column, you need to compare the name of each column in the RowSet with the required name. To do so −Retrieve the ResultSetMetaData object from the RowSet using the getMetaData() method.ResultSetMetaData meta = rowSet.getMetaData();Get the number of columns in the RowSet using the getColumnCount() method.int columnCount = meta.getColumnCount();The getColumnName() method returns the name of the column of the specified index. Using this method retrieve the column names of the RowSet from index 1 to column count and compare ...

Read More

What is the difference between static_cast<> and C style casting?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 4K+ Views

Here we will see what are the differences between static_cast and normal C style cast.The normal cast like (int)x is C style typecasting where static_cast(x) is used in C++.This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast the intensions are conveyed much better.In C like cast sometimes we can cast some type pointer to point some other type data.Like one integer pointer can also point character type data, as they are quite similar, only difference is character has ...

Read More

How to activate and deactivate JFrame in Java

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 609 Views

Here, we are activating a frame. For deactivation, we have used dispose −Thread.sleep(2000); frame.setVisible(false);The frame first activates and then deactivates after 2 seconds since we have set sleep to 2000 miliseconds.The following is an example to activate and deactivate JFrame −Exampleimport java.awt.Frame; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo {    public static void main(String[] args) throws InterruptedException {       JFrame frame = new JFrame();       frame.add(new JLabel("Demo"));       frame.pack();       frame.setVisible(true);       Thread.sleep(2000);       frame.setState(Frame.ICONIFIED);       Thread.sleep(2000);       frame.setVisible(false);       frame.dispose(); ...

Read More

What are the sizes of the icons in Android notifications action-buttons?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 214 Views

Asset Size: 32dp x 32dp Optical Square: 24dp x 24dp Color (Enabled): #FFFFFF 80% opacity Color (Disabled): #FFFFFF 30% opacityClick  here  to download the project code

Read More

How to pull even numbers from an array in MongoDB?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 626 Views

Use $mod to get the even numbers and pull them from the array. Let us first create a collection with documents −>db.pullEvenNumbersDemo.insertOne({"AllNumbers":[101, 102, 104, 106, 108, 109, 110, 112, 14, 17, 18, 21]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd45b072cba06f46efe9eea") }Following is the query to display all documents from the collection with the help of find() method −> db.pullEvenNumbersDemo.find().pretty();This will produce the following output −{    "AllNumbers" : [       102,       104,       106,       108,       109,       110,       112,   ...

Read More

Java Program to display JTabbedPane on the right

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 179 Views

To display JTabbedPane on the right, you need to set the location to the right using the constant RIGHT −JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);The following is an example to display JTabbedPane on the right −Examplepackage my; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Technologies");       JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);       JPanel panel1, panel2, panel3, panel4, panel5;       panel1 = new JPanel();       panel2 = new JPanel();       panel3 = new JPanel();       panel4 = ...

Read More
Showing 56811–56820 of 61,248 articles
Advertisements