Anvi Jain has Published 500 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

1K+ 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

330 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

468 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

461 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

How to retrieve binary data from a table using JDBC?

Anvi Jain

Anvi Jain

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

1K+ 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

MongoDB query to exclude both the fields with FALSE

Anvi Jain

Anvi Jain

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

420 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

Delete the first 10 characters from JTextArea in Java

Anvi Jain

Anvi Jain

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

497 Views

Let’s say the following is our JTextArea with default text −JTextArea textArea = new JTextArea("The text added here is just for demo. "    + "This demonstrates the usage of JTextArea in Java. In this example we have"    + "deleted some text.");Now to remove the first 10 characters, use ... Read More

How to Read data from BLOB and CLOB type columns from a table using JDBC?

Anvi Jain

Anvi Jain

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

6K+ Views

Clob datatypeCLOB stands for Character Large Object. in general, an SQL Clob is a built-in datatype which is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters. MYSQL database provides support Clob datatype TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT.The ... Read More

Advertisements