The fill() method in HTML canvas is used to fill the current drawing path. The default is black. The element allows you to draw graphics on a web page using JavaScript. Every canvas has two elements that describes the height and width of the canvas i.e. height and width respectively.Following is the syntax−ctx.fill();Let us now see an example to implement the fill() method of canvas −Example Live Demo Your browser does not support the HTML5 canvas tag. var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath(); ... Read More
To get the current size of a table, use the following that will display details about a table including the size −show table status like ‘yourTableName’\GLet us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> CustomerAge int, -> CustomerCountryName varchar(20) -> ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(CustomerName, CustomerAge, CustomerCountryName) values('John', 24, 'US'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(CustomerName, CustomerAge, CustomerCountryName) ... Read More
To get JFrame window size information, you can use the following −environment.getMaximumWindowBounds();For Screen Size −config.getBounds()For Frame Size −frame.getSize());The following is an example to get JFrame window size information −Exampleimport java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javax.swing.JFrame; public class SwingDemo { public static void main(String[] args) { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = environment.getMaximumWindowBounds(); System.out.println("Screen Bounds = " + bounds); GraphicsDevice device = environment.getDefaultScreenDevice(); GraphicsConfiguration config = device.getDefaultConfiguration(); System.out.println("Screen Size = " + config.getBounds()); JFrame frame ... Read More
This example demonstrate about How to display a custom alert or a view on receiving a notification 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.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 ; import android.widget.Toast ; public class MainActivity extends AppCompatActivity { public static final String NOTIFICATION_CHANNEL_ID = "10001" ... Read More
You can use aggregate framework for this. Let us first create a collection with documents −>db.aggregationOperatorDemo.insertOne({"FirstValue":392883,"SecondValue":10000000000}); { "acknowledged" : true, "insertedId" : ObjectId("5cd541452cba06f46efe9f01") }Following is the query to display all documents from a collection with the help of find() method −> db.aggregationOperatorDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd541452cba06f46efe9f01"), "FirstValue" : 392883, "SecondValue" : 10000000000 }Following is the query to use divide aggregation operator −> db.aggregationOperatorDemo.aggregate([ ... { "$project": { "Value": { "$divide": ["$FirstValue", "$SecondValue"] } } } ... ]);This will produce the following output −{ "_id" : ObjectId("5cd541452cba06f46efe9f01"), "Value" : 0.0000392883 }
To find a node in a JTree component, use the getNextMatch() method. Here, wer are trying to find a node that begins with character “A”. The search begins from the node set below with begnRow variable −int begnRow = 0; String prefix = "A"; TreePath treePath = tree.getNextMatch(prefix, begnRow, Position.Bias.Forward);We have displayed the resultant node in the Console −System.out.println("Node = "+treePath);The following is an example to find a node in a JTree Component with Java −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.text.Position; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; public class SwingDemo { public static void main(String[] args) throws Exception { ... Read More
Let us see how to set the raised SoftBevelBorder −Border raisedBorder = new SoftBevelBorder( SoftBevelBorder.RAISED, Color.GREEN, Color.GREEN.darker(), Color.MAGENTA, Color.magenta.brighter());Let us see how to set the lowered SoftBevelBorder −Border loweredBorder = new SoftBevelBorder( SoftBevelBorder.LOWERED, Color.ORANGE, Color.YELLOW.darker(), Color.BLUE, Color.yellow.brighter());The following is an example to set raised and lowered SoftBevelBorder for components in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.Border; import javax.swing.border.SoftBevelBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = ... Read More
Let us first create a collection with documents −> db.findDataDemo.insertOne( { "_id": new ObjectId(), "CustomerName":"John", "CustomerDetails" : { "CountryName" : [ "AUS" ], "isMarried" : [ false ] } } ); { "acknowledged" : true, "insertedId" : ObjectId("5cefa5eeef71edecf6a1f6a5") } > db.findDataDemo.insertOne( { "_id": new ObjectId(), "CustomerName":"Carol", ... Read More
GeneratorsJavaScript supports Generator functions and Generator Objects. A generator function is the same as a normal function, but whenever it needs to generate a value it uses the 'yield' keyword rather than 'return'. The 'yield' keyword halts the function execution and sends a value back to the caller. It has an ability that it can resume the functionality from where it is left off. syntaxfunction* generator(){ yeild 1; yeild 2; }ExampleIn the following example, using a generator function, natural numbers 10, 9 and 8 were printed. Instead of printing each number individually we can run ... Read More
Following is the syntax −select table_name, create_time from information_schema.TABLES where table_schema = 'yourDataBaseName' order by CREATE_TIME desc limit 1;Let us create the first table (Time: 2019-06-10 16:40:51) −mysql> create table DemoTable1 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query OK, 0 rows affected (0.59 sec)We will now create the second table, let’s say after 5 minutes −mysql> create table DemoTable2 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int -> ); Query ... Read More