Display Vertical and Horizontal Scrollbars Always in HTML

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

111 Views

Use the following constants for the JScrollBar to display the vertical and horizontal scrollbars always even if it is not required −scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);The following is an example to display the vertical and horizontal scrollbars always even if it is not required −Examplepackage my; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Demo");       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JButton button1 = new JButton("Questions and Answers");       JButton button2 = new JButton("Videos");       JButton ... Read More

Get First Item from Array Property in MongoDB

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

429 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"},          {"UserFriendName":"Bob"}       ]    } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cdfca52bf3115999ed51205") }Following is the query to display all documents from a collection with the help of find() method −> db.gettingFirstItemInArrayDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cdfca52bf3115999ed51205"),    "UserId" : 101, ... Read More

MySQL Datatype to Store Datalink Object in JDBC

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

429 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 −CREATE TABLE tutorials_data (    tutorial_id INT PRIMARY KEY AUTO_INCREMENT,    tutorial_title VARCHAR(100),    tutorial_author VARCHAR(40),    submission_date date,    tutorial_link VARCHAR(255) );Following JDBC program establishes a connection with MYSQL database, creates a table with name tutorials_data. In this table we are creating a column with name tutorial_link which stores ... Read More

HTML DOM Input URL DefaultValue Property

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

132 Views

The HTML DOM Input URL defaultValue property sets/returns the default value corresponding to URL Input. The value attribute changes as the user types in the URL input but default value does not change.SyntaxFollowing is the syntax −Returning string valueinputURLObject.defaultValueSetting defaultValue to stringinputURLObject.defaultValue = ‘string’ExampleLet us see an example of Input URL defaultValue property − Live Demo Input URL defaultValue    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {     ... Read More

Bool to Int Conversion in C++

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

13K+ Views

Here we will see how to convert bool to int equivalent in C++. Bool is a datatype in C++, and we can use true or false keyword for it. If we want to convert bool to int, we can use typecasting. Always true value will be 1, and false value will be 0.Example#include using namespace std; main() {    bool my_bool;    my_bool = true;    cout

Change JLabel Font in Java

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

14K+ Views

To change JLabel font, use the setFont() method −JLabel lable = label.setFont(new Font("Verdana", Font.PLAIN, 18));Examplepackage my; import java.awt.Font; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Label Example");       JLabel label;       label = new JLabel("First Label");       label.setBounds(50, 50, 100, 30);       label.setFont(new Font("Verdana", Font.PLAIN, 18));       frame.add(label);       frame.setSize(300,300);       frame.setLayout(null);       frame.setVisible(true);    } }Output

Display Count of Notifications in Android App Launcher Icon

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

3K+ Views

This example demonstrate about How to display count of notifications in Android app launcher icon.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.                                                                         Let's try to run your application. I assume you have connected ... Read More

Check If Two Nodes Are Equal in a JTree with Java

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

795 Views

To check if two nodes are equal, use the equals() method. Here, we are checking that node1 and node2 are equal or not.node1.equals(node2)The following is an example to check if two nodes are equal in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Website");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Videos");       DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Tutorials");       DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("QA");     ... Read More

Make JSlider Vertical and Move Top to Bottom in Java

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

268 Views

To set the JSlider to be vertical, use the VERTICAL constant while creating the slider −JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);Now, for the inverted slider i.e. moving from top-to-bottom −slider.setInverted(true);The following is an example to set the slider vertical and move top-to-bottom −Examplepackage my; 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.VERTICAL, 0, 100, 60);       slider.setInverted(true);       slider.setMinorTickSpacing(5);       slider.setMajorTickSpacing(20);     ... Read More

Find Documents That Contain Specific Field in MongoDB

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

181 Views

For this, use the $exists operator. Let us first create a collection with documents −>dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product1":10, "Pr oduct2":50}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2385bb64a577be5a2bc14") } >dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product3":150, "P roduct7":100, "Product5":250}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2387eb64a577be5a2bc15") }Following is the query to display all documents from a collection with the help of find() method −> dbfindDocumentContainsSpecificFieldDemofind()pretty();This will produce the following document −{    "_id" : ObjectId("5cf2385bb64a577be5a2bc14"),    "ProductPrices" : {       "Product1" : 10,       "Product2" : 50    } } {    "_id" : ObjectId("5cf2387eb64a577be5a2bc15"),    "ProductPrices" : {       ... Read More

Advertisements