Change Minimum Value of a JSlider in Java

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

258 Views

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

Check Whether Field Exists in MongoDB

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

243 Views

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

HTML DOM Input Color Name Property

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

131 Views

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

HTML DOM Input Time Disabled Property

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

147 Views

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

Interesting Facts About C Programming

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

472 Views

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

Get List of Databases and Collections on MongoDB Server

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

219 Views

To get a list of all databases, you need to use the below syntax −use admin db.runCommand({listDatabases: 1});To get a list of all collection names of a particular database, you need to use below syntax −use yourDatabaseName; db.getCollectionNames();Let us implement the above syntaxes −Case 1 − To get a list of databases> use admin switched to db admin > db.runCommand({listDatabases: 1});This will produce the following output −{    "databases" : [       {          "name" : "admin",          "sizeOnDisk" : 1675264,          "empty" : false   ... Read More

Create Right Justified JTextField in Java

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

2K+ Views

To create right justified JTextField, set the alignment to be RIGHT. Here, we will be using the setHorizontalAlignment() method as well and within that the alignment would be set.Create a JTextField −JTextField emailId = new JTextField(20);Now, align it to the right −emailId.setHorizontalAlignment(JTextField.RIGHT);The following is an example to create right justified JTextField −Examplepackage my; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.SwingConstants; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Enter emailid...");       JLabel label;       frame.setLayout(new FlowLayout());       label = ... Read More

Remove Array Elements from a Document in MongoDB

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

254 Views

Use the $pull to remove array elements from a MongoDB document as shown in the following syntax −db.yourCollectionName.update( { }, { $pull: { yourFieldName: yourValue }}, {multi:true });Let us first create a collection with documents −>db.removeArrayElementsDemo.insertOne({"AllPlayerName":["John", "Sam", "Carol", "David"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd90d011a844af18acdffc1") } >db.removeArrayElementsDemo.insertOne({"AllPlayerName":["Chris", "Robert", "John", "Mike"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd90d2e1a844af18acdffc2") }Following is the query to display all documents from a collection with the help of find() method −> db.removeArrayElementsDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd90d011a844af18acdffc1"),    "AllPlayerName" : [       "John",   ... Read More

HTML DOM Input Color Object

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

180 Views

The HTML DOM Input Color Object represents an input HTML element with type color.SyntaxFollowing is the syntax −Creating an with type color −var colorObject = document.createElement(“input”); colorObject.type = “color”;AttributesHere, “colorObject” can have the following attributes −AttributesDescriptionautocompleteIt defines the value of autocomplete attribute of a color pickerautofocusIt defines if the color picker should be focused on initial page load.defaultValueIt sets/returns the default value of color pickerdisabledIt defines if color picker is disabled/enabledformIt returns a reference of enclosing form that contains the color pickernameIt defines the value of name attribute of a color pickertypeIt returns the type of form element of ... Read More

HTML DOM Input Time Form Property

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

154 Views

The HTML DOM Input Time form property returns the reference of enclosing form for input Time.SyntaxFollowing is the syntax −Returning reference to the form objectinputTimeObject.formExampleLet us see an example of Input Time form property − Live Demo Input Time form    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Time-form Examination Time :    var divDisplay = document.getElementById("divDisplay");    var inputTime = document.getElementById("TimeSelect");    function getform() {       divDisplay.textContent = inputTime.form.id+' exam starts from '+inputTime.value;    } OutputThis will produce the following output −Before clicking ‘Which Exam?’ button −After checking ‘Which Exam?’ button −

Advertisements