Anvi Jain has Published 629 Articles

How to set font face, style, size and color for JTextPane text in Java

Anvi Jain

Anvi Jain

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

956 Views

For background and foreground color of the JTextPane, use the following −JTextPane textPane = new JTextPane(); textPane.setBackground(Color.blue); textPane.setBackground(Color.green);For font face, style and size, use the Font class and set the font −Font font = new Font("Serif", Font.ITALIC, 18); textPane.setFont(font);The following is an example to set font, style and color for ... Read More

How to execute a task repeatedly after fixed time intervals in iOS

Anvi Jain

Anvi Jain

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

229 Views

Apple has predefined class Timer, that fires after a certain time interval has elapsed, sending a specified message to a target object.To read more about the Timer class you can check official apple documentation herehttps://developer.apple.com/documentation/foundation/timerTo execute the task repeatedly after fixed interval of time we are going to use timer ... Read More

How to implement an Android notification action without opening the app?

Anvi Jain

Anvi Jain

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

1K+ Views

This example demonstrate about How to implement an Android notification action without opening the 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.xml.   ... Read More

Getting only the first item for an array property in MongoDB?

Anvi Jain

Anvi Jain

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

314 Views

Use $slice operator for this. Let us first create a collection with documents −> db.gettingFirstItemInArrayDemo.insertOne(    {       "UserId": 101,       "UserName":"Carol",       "UserOtherDetails": [          {"UserFriendName":"Sam"},          {"UserFriendName":"Mike"},          {"UserFriendName":"David"},         ... Read More

What is the MySQL datatype to store DATALINK object in JDBC

Anvi Jain

Anvi Jain

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

328 Views

A DATALINK object represents an URL value which refers to an external resource (outside the current database/data source), which can be a file, directory etc..MySQL does not provide any separate datatype to store DATALINK/URL value you need to store using TEXT or VARCHAR datatypes as shown in the following query ... Read More

Is POW() better or POWER() in MySQL?

Anvi Jain

Anvi Jain

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

108 Views

Both pow() and power() are synonyms. Let us see the syntax −select pow(yourValue1, yourValue2); OR select power(yourValue1, yourValue2);Now we will see some examples.Using pow()mysql> select POW(4, 3);This will produce the following output −+----------+ | POW(4, 3) | +----------+ | 64 | +----------+ ... Read More

How to retrieve binary data from a table using JDBC?

Anvi Jain

Anvi Jain

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

752 Views

SQL databases provide a datatype named Blob (Binary Large Object) in this, you can store large binary data like images.To retrieve binary (stream) values from a table JDBC provides a method called getBinaryStream() in the PreparedStatement interface.It accepts an integer representing the index of the column of the table and ... Read More

Java Program to deselect all cells in a JTable

Anvi Jain

Anvi Jain

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

343 Views

At first, let’s say, we have selected a row using addRowSelectionInterval() as shown in the demo screenshot −Now, we will deselect all these cells using clearSelection() as shown in the following example. This method clears the selected cells from the table −Examplepackage my; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import ... Read More

MongoDB query to exclude both the fields with FALSE

Anvi Jain

Anvi Jain

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

294 Views

Use $or operator along with $expr operator for this. Let us first create a collection with documents, wherein one of fields is isMarried having true of false value −> db.orTwoFieldsDemo.insertOne({"isLiveInUS":true, "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdfd86abf3115999ed5120d") } > db.orTwoFieldsDemo.insertOne({"isLiveInUS":true, "isMarried":true}); {    "acknowledged" : true,   ... Read More

What is the Java equivalent to MySQL's smallint?

Anvi Jain

Anvi Jain

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

2K+ Views

The short is equivalent to MySQL’s small int. The Java short takes 2 bytes that has the range -32768 to 32767 while MySQL smallint also take 2 bytes with same range.Here is the demo code of short in Java −public class SmallIntAsShortDemo {    public static void main(String[] args) { ... Read More

Advertisements