Use the setVgap() method to set the vertical gap between elements in a GridLayout. Let’s say we have a GridLaypout −GridLayout layout = new GridLayout(3, 3);Set the horizontal gap −layout.setVgap(30);The following is an example −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Sections"); JPanel panel = new JPanel(); panel.setBackground(Color.blue); GridLayout layout = new GridLayout(3, 3); ... Read More
Yes, we can avoid the _id, using the following syntax in MongoDB −db.yourCollectionName.find({}, { _id:0});Let us first create a collection with documents:>> db.excludeIdDemo.insertOne({"CustomerName":"Larry"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7f62c1a844af18acdffb9") } > db.excludeIdDemo.insertOne({"CustomerName":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7f6311a844af18acdffba") } > db.excludeIdDemo.insertOne({"CustomerName":"Mike"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7f6351a844af18acdffbb") } > db.excludeIdDemo.insertOne({"CustomerName":"Bob"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7f6381a844af18acdffbc") }Following is the query to display all documents from a collection with the help of find() method −> db.excludeIdDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd7f62c1a844af18acdffb9"), "CustomerName" : "Larry" } ... Read More
The Input Color form property returns the reference of enclosing form for input color.SyntaxFollowing is the syntax −Returning reference to the form objectinputColorObject.formExampleLet us see an example of Input Color form property − Live Demo Input Color Form Color Picker: Get Form ID function getFormID() { var inputColor = document.getElementById("Color"); var divDisplay = document.getElementById("divDisplay"); divDisplay.textContent = 'Form ID for color input: '+inputColor.form.id; } OutputThis will produce the following output −Before clicking ‘Get Form ID’ button −After clicking ‘Get Form ID’ button −
When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The isBeforeFirst() method of the ResultSet interface is used to determine whether the cursor is at the default position of the ResultSet.rs.isBeforeFirst();This method returns an boolean this value is true, if the cursor is ... Read More
You can use $setIntersection operator along with aggregate framework to filter array elements in MongoDB. Let us first create a collection with documents −> db.filterArrayElementsDemo.insertOne( { "Scores": [10, 45, 67, 78, 90, 98, 99, 92] } ); { "acknowledged" : true, "insertedId" : ObjectId("5cd2d582b64f4b851c3a13c8") }Following is the query to display all documents from a collection with the help of find() method −> db.filterArrayElementsDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd2d582b64f4b851c3a13c8"), "Scores" : [ 10, 45, 67, 78, 90, ... Read More
To change the minimum value of a slider in Java, use the setMinimum() method wherein set the minimum value.Let’s say the following is our slider in Java −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true);Now, set the minimum value −slider.setMinimum(10);The following is an example to change the minimum value of a JSlider −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, ... Read More
You can use $exists operator for this. Let us first create a collection with documents −>db.checkFieldExistsDemo.insertOne({"StudentFirstName":"John", "StudentGender":"Male", "StudentMongoDBScore":89}); { "acknowledged" : true, "insertedId" : ObjectId("5cd909611a844af18acdffbd") } >db.checkFieldExistsDemo.insertOne({"StudentFirstName":"Emma", "StudentGender":"Female", "StudentMongoDBScore":58}); { "acknowledged" : true, "insertedId" : ObjectId("5cd909781a844af18acdffbe") } >db.checkFieldExistsDemo.insertOne({"StudentFirstName":"Carol", "StudentGender":"Male", "StudentMongoDBScore":77}); { "acknowledged" : true, "insertedId" : ObjectId("5cd909871a844af18acdffbf") } >db.checkFieldExistsDemo.insertOne({"StudentFirstName":"David", "StudentMongoDBScore":98}); { "acknowledged" : true, "insertedId" : ObjectId("5cd909a31a844af18acdffc0") }Following is the query to display all documents from a collection with the help of find() method −> db.checkFieldExistsDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd909611a844af18acdffbd"), "StudentFirstName" : "John", "StudentGender" ... Read More
The Input Color name property returns a string, which is the value of the input color name attribute. User can also set it to a new string.SyntaxFollowing is the syntax −Returning string valueinputColorObject.nameSetting name attribute to a string valueinputColorObject.name = ‘String’ExampleLet us see an example of Input Color name property − Live Demo Input Color Name Color Picker: Change name value var inputColor = document.getElementById("Color"); var divDisplay = document.getElementById("divDisplay"); divDisplay.textContent = 'Name of color input: '+inputColor.name; function changeNameValue() { if(inputColor.name == 'primaryColor'){ inputColor.name ... Read More
The HTML DOM Input Time disabled property sets/returns whether Input Time is enabled or disabled.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputTimeObject.disabledSetting disabled to booleanValueinputTimeObject.disabled = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailstrueIt defines that the input time is disabled.falseIt defines that the input time is not disabled and it is also the default value.ExampleLet us see an example of Input Time disabled property − Live Demo Input Time disabled form { width:70%; margin: 0 auto; text-align: center; } * { ... Read More
Here we will see some interesting facts about C programming. These are like below.Sometimes the case labels of some switch statement can be placed inside if-else statement.Example#include main() { int x = 2, y = 2; switch(x) { case 1: ; if (y==5) { case 2: printf("Hello World"); } else case 3: { //case 3 block ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP