HTML DOM Location Hash Property

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

239 Views

The Location hash property returns/appends a string value (anchor part) to a URL. Anchor part is prefixed with ‘#’ automatically and then appended.SyntaxFollowing is the syntax −Returning value of the hash propertylocation.hashValue of the hash property setlocation.hash = ‘string’ExampleLet us see an example for Location hash property − Live Demo Location hash    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } ... Read More

Check Selected Items in Java JList

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

775 Views

To check if there are any selected items, use the following:boolean res = !list.isSelectionEmpty();The value of res would be TRUE IF we have a selected item in the JList.The following is an example to check if there are any selected items in 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[]= {"Squash", ... Read More

ResultSet Holdability in JDBC

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

2K+ Views

ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ ResultSet object) is committed using the commit() method of the Connection interface.You can set the ResultSet holdability using the setHoldability() method of the Connection interface.con.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);The ResultSet interface provides two values to specify the holdability of a ResultSet namely CLOSE_CURSORS_AT_COMMIT and, HOLD_CURSORS_OVER_COMMIT.Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),   ... Read More

Find Datatype of All Fields in MongoDB

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

4K+ Views

Use typeof to find datatype of all the fields −typeof db.yourCollectionName.findOne().yourFieldName;Let us first create a collection with documents −> db.findDataTypeDemo.insertOne({"ClientName":"Chris", "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccf2064dceb9a92e6aa1952") }Following is the query to display all documents from a collection with the help of find() method −> db.findDataTypeDemo.findOne();This will produce the following output −{    "_id" : ObjectId("5ccf2064dceb9a92e6aa1952"),    "ClientName" : "Chris",    "isMarried" : false }Following is the query to find datatype of a field in MongoDB −> typeof db.findDataTypeDemo.findOne().isMarried;This will produce the following output −BooleanHere is the query to get the data type of another field −> ... Read More

Determine When a Frame or Window is Opened in Java

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

946 Views

To determine when a Window is opened in Java, use the WindowListener, which is the listener interface for receiving window events..WindowListener listener = new WindowAdapter() {    public void windowOpened(WindowEvent evt) {       Frame frame = (Frame) evt.getSource();       System.out.println("Opened "+frame.getTitle());    } };Above, we have used the windowOpened() method, which is invoked when a window has been opened −public void windowOpened(WindowEvent evt) {    Frame frame = (Frame) evt.getSource();    System.out.println("Opened "+frame.getTitle()); }The following is an example to determine when a frame or window is opened in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import ... Read More

Exclude ID Without Including Other Fields Using Aggregation Framework in MongoDB

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

841 Views

Let us first create a collection with documents −> db.excludeIdDemo.insertOne({"StudentFirstName":"John", "StudentAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701a56d78f205348bc632") } > db.excludeIdDemo.insertOne({"StudentFirstName":"Robert", "StudentAge":20}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701af6d78f205348bc633") } > db.excludeIdDemo.insertOne({"StudentFirstName":"Chris", "StudentAge":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd701b86d78f205348bc634") }Following is the query to display all documents from a collection with the help of find() method −> db.excludeIdDemo.find();This will produce the following output −{ "_id" : ObjectId("5cd701a56d78f205348bc632"), "StudentFirstName" : "John", "StudentAge" : 21 } { "_id" : ObjectId("5cd701af6d78f205348bc633"), "StudentFirstName" : "Robert", "StudentAge" : 20 } { "_id" : ObjectId("5cd701b86d78f205348bc634"), "StudentFirstName" : "Chris", "StudentAge" ... Read More

HTML Input Size Attribute

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

447 Views

The size attribute of the element is used to set the width of the input. The more the width would lead to a textbox with more width. You can set the size attribute for the following input types − text, search, email, password, tel and url.Following is the syntax −Above, size_num is the width of the input you need to set in numbers. The default is 20.Let us now see an example to implement the size attribute of the element −Example Live Demo Register Id − Password − ... Read More

Restrictions on Method Overloading in Java

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

1K+ Views

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Example Live Democlass Test{ public int division(int a, int b){ int result = a/b; return result; } public double division (float a, float b){ double result = ... Read More

HTML DOM Input Number Form Property

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

116 Views

The HTML DOM input number form property returns the reference of the form that contains the number input field in the HTML document.SyntaxFollowing is the syntax −object.formExampleLet us see an example of HTML DOM input number form property − Live Demo body{ text-align:center; background-color:#1b203a; color:#fff; } form{ margin:2.5rem auto; border:1px solid #fff; padding:2rem; ... Read More

HTML DOM Table Object

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

771 Views

The HTML DOM table Object represent the element of an HTML document.Let us see how to create table objectSyntaxFollowing is the syntax −document.createElement(“TABLE”);PropertiesFollowing are the properties of table object −PropertyExplanationcaptionIt returns element of a table in an HTML document.tFootIt returns element of a table in an HTML document.tHeadIt returns element of a table in an HTML document.MethodsFollowing are the methods of table object −MethodExplanationcreateCaption()It generates an empty element and adds it to the table.createTFoot()It generates an empty element and adds it to the table.createTHead()It generates an empty element and adds it to the ... Read More

Advertisements