To set the border color for SoftBevelBorder in Java, use the Color class and set the color while creating the border −SoftBevelBorder border = new SoftBevelBorder( BevelBorder.RAISED, Color.ORANGE, Color.ORANGE.darker(), Color.BLUE, Color.magenta.brighter());We have set the following colors above as parameters −highlightOuterColor: color to use for the bevel outer highlight highlightInnerColor : color to use for the bevel inner highlight shadowOuterColor : color to use for the bevel outer shadow shadowInnerColor : color to use for the bevel inner shadowThe following is an example to set border color for SoftBevelBorde in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import ... Read More
Let us first create a collection with documents -> db.operatorDemo.insertOne({"StudentSubject":["MongoDB", "MySQL", "Java"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cef94eaef71edecf6a1f6a2") } > db.operatorDemo.insertOne({"StudentSubject":["Java", "C", "C++"]}); { "acknowledged" : true, "insertedId" : ObjectId("5cef94faef71edecf6a1f6a3") }Display all documents from a collection with the help of find() method -> db.operatorDemo.find().pretty();Output{ "_id" : ObjectId("5cef94eaef71edecf6a1f6a2"), "StudentSubject" : [ "MongoDB", "MySQL", "Java" ] } { "_id" : ObjectId("5cef94faef71edecf6a1f6a3"), "StudentSubject" : [ "Java", "C", "C++" ] }Following is the query for ... Read More
The element in HTML in HTML 4 was used to underlined a text on a web page, but HTML5 redefined to display text different from normal text.Let us now see an example to implement the tag−Example Live Demo Shortcut Keys Use the following shortcut keys: Cut: CTRL+X Copy: CTRL+C Paste: CTRL+V Undo: CTRL+Z OutputIn the above example, we have used the tag to display a text other than the default normal text−Use the following shortcut keys: Cut: CTRL+X
For this, use ORDER BY clause. The current date is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 21:08:16 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> DueDate datetime -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(DueDate) values('2019-06-12'); Query OK, 1 row affected (0.24 sec) ... Read More
Here we will see what are the differences of sizeof and the alignof operator in C++. The alognof() operator is introduced in C++11.The alignof() operator is used to get the alignment in bytes. It requires instances of type. the type is either complete type or a reference type. There is another operator called the sizeof() operator, that returns the size of one type. For normal datatypes the sizeof and the alignof returns the same value. For some user defined datatype, the alignof returns some different value. Let us see the example to get the idea.Example Live Demo#include using namespace std; struct ... Read More
To select the second index, use the setSelectedIndex() method −JList new JList(sports); list.setSelectedIndex(2);The following is an example to select the second index in Java JList −Examplepackage my; import java.awt.event.*; import java.awt.*; import javax.swing.*; class SwingDemo extends JFrame { static JFrame frame; static JList list; public static void main(String[] args) { frame = new JFrame("JList Demo"); SwingDemo s = new SwingDemo(); JPanel panel = new JPanel(); String sports[]= { "Cricket","Football","Hockey","Rugby"}; list = new JList(sports); list.setSelectedIndex(2); panel.add(list); frame.add(panel); frame.setSize(400,400); frame.setVisible(true); } }Output
This example demonstrate about How to play a custom sound on receiving notification 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 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.Activity ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.content.Intent ; import android.media.RingtoneManager ; import android.net.Uri ; import android.os.Bundle ; import android.support.annotation. Nullable ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity ... Read More
To update the inner field, use the below syntax −db.yourCollectionName.update({"_id" : yourObjectId}, {$set : {"yourOuterFieldName.yourInnerFieldName" :yourValue}});Let us first create a collection with documents −> db.updateDocumentDemo.insertOne( ... { ... ... "StudentDetails" : { ... "StudentFirstName" : "Adam", ... "StudentLastName" : "Samith" ... }, ... "StudentOtherDetails" : { ... "StudentFavouriteSubject" : "MySQL", ... "StudentScore" : 45 ... } ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5cd50bb32cba06f46efe9efe") }Following is the query to ... Read More
To set FlowLayout for a frame, use the Container. At first, set a JFrame −JFrame frame = new JFrame();Now, use Container and set the layout as FlowLayout−Container container container = frame.getContentPane(); container.setLayout(new FlowLayout());The following is an example to set FlowLayout for JFrame −Examplepackage my; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; public class SwingDemo { public static void main(String[] val) { JFrame frame = new JFrame(); Container container; JButton btn; frame.setBounds(20, 20, 15, 15); container = frame.getContentPane(); container.setLayout(new ... Read More
To set TitleBorder direction, you need to use the constants and set it for border. For example, for direction center −TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER);Above, we have set the setTitlePosition() for the direction.The following is an example to set TitledBorder direction in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER); TitledBorder border2 = new TitledBorder( ... Read More