Let’s say we have set the following values for JProgressBar −int min = 0; int max = 1000; progressBar = new JProgressBar(min, max);Now, get the above values and display in the Console −int value = progressBar.getValue(); System.out.println("Value = "+value); System.out.println("Minimum = "+progressBar.getMinimum()); System.out.println("Maximum = "+progressBar.getMaximum());The following is an example to get the values of a progress bar component −Examplepackage my; import javax.swing.*; public class SwingDemo extends JFrame { JProgressBar progressBar; int i = 0; SwingDemo() { int min = 0; int max = 1000; progressBar = new JProgressBar(min, ... Read More
Here we will see how to check whether two nibbles of a number are same or not.Problem StatementWrite 8085 Assembly language program to check whether upper nibble and lower nibbles are same or not.DiscussionTo check the nibbles, we have to mask at first. So we need to mask the lower nibble and upper nibble and store them into different registers. The upper nibble will be shifted to the right four bits to make it lower nibble. Then we can check both are same or not. If they are same store 00 at F150 location, otherwise store FF at F150 location.InputAddressDataF050FE AddressDataF050AA Flow ... Read More
To get distinct first word from a string, you can use distinct(). Let us first create a collection with documents −> db.distinctFirstWordDemo.insertOne( { "_id": 100, "StudentName":"John", "StudentFeature": "John is a good player", "Subject":"MongoDB" } ); { "acknowledged" : true, "insertedId" : 100 } > db.distinctFirstWordDemo.insertOne( { "_id": 101, "StudentName":"Carol", "StudentFeature": "Carol is not a good player", "Subject":"MongoDB" } ); { "acknowledged" : true, "insertedId" : 101 }Display all documents from a collection ... Read More
The autocomplete attribute of the element allows you to set whether the autocomplete for the form should be on or off. The web browser automatically fills the values if the autocomplete is on. This only happens if the user already entered values before.Following is the syntax −Above, on | off values are to be set for autocomplete to appear or not. Set on if you want the browser to complete the entries based on previously entered values, whereas off doesn’t allow to complete the entries.Let us now see an example to implement the autocomplete attribute of the element ... Read More
The average of the square of Natural Number is calculated by adding all the squares up to n natural numbers and then dividing it by the number.SampleAverage of square of first 2 natural numbers is 2.5 ,12 + 22 = 5 => 5/2 = 2.5.There are two methods for calculating this is programming −Using LoopsUsing FormulaCalculating average of square of natural numbers using loopsThis logic works by finding the squares of all natural numbers. By loop from 1 to n finding square of each and adding to the sum variable. Then dividing this sum by n.Program to find the sum ... Read More
The HTML DOM Input Week readOnly property sets/returns whether Input Week can be modified or not.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputWeekObject.readOnlySetting readOnly to booleanValueinputWeekObject.readOnly = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailstrueIt defines that the input week field is readOnly.falseIt defines that the input week field is not readOnly and can be modified.ExampleLet us see an example for Input Week readOnly property − Live Demo Input Week readOnly form { width:70%; margin: 0 auto; text-align: center; } * { padding: ... Read More
This is a C++ program to find the Mode in a data set.AlgorithmsBegin function insertinset() to insert data in the set. Create newnode and temp(t) node. Node to be inserted in the list using newnode. If head is null then assign new node to head and increase the count. During insertion perform insertion sort for sorting data. If the newnode->data is equal to any of the element present in the set, then just increment count. EndExample#include using namespace std; struct set // a structure set to declare ... Read More
This method retrieves the list of all the SQL keywords of the underlying database and returns in the form of a String variable which holds all the keywords separated by commas.To get the list of keywords in the database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.Get the DatabaseMetaData ... Read More
You can use ORDER BY RIGHT() for this. Let us first create a table −mysql> create table DemoTable ( UserId varchar(100) ); Query OK, 0 rows affected (0.33 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('User1234'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values('User9874'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('User9994'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable values('User1211'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('User1012'); Query OK, 1 ... Read More
Use SpinnerNumberModel to create a spinner with value as numbers −SpinnerModel value = new SpinnerNumberModel(10, 0, 20, 1);Now set the values −JSpinner spinner = new JSpinner(value);The following is an example to create a JSpinner with values as numbers −Examplepackage my; import java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Spinner Demo"); SpinnerModel value = new SpinnerNumberModel(10, 0, 20, 1); JSpinner spinner = new JSpinner(value); spinner.setBounds(50, 80, 70, 100); frame.add(spinner); frame.setSize(550,300); frame.setLayout(null); frame.setVisible(true); } }This will produce the following output −