Remove a menu from the MenuBar using the remove() method. Set the index for the menu you want to remove from the MenuBar.Let’s say we have the following two menus initially −The following is an example to remove one the above menus. Let’s say we are removing the 2nd menus “Edit” −Examplepackage my; import java.awt.event.KeyEvent; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class SwingDemo { public static void main(final String args[]) { JFrame frame = new JFrame("MenuBar Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); JMenu ... Read More
Objects created using object literal are singletons, this means when a change is made to the object, it affects the object entire the script. Whereas if an object is created using constructor function and a change is made to it, that change won't affect the object throughout the script. Let's discuss them individually.1) Objects created using object literalSince these are singletons, a change to an object persists throughout the script. A change in one instance will affect all the instances of the object. In the following example if we observe, both the objects "student" and "newStudent" display the same name(Ravi) initially. But ... Read More
The HTML DOM Input Color defaultValue property sets/returns the default value corresponding to a color. It may or may not be same as value attribute.SyntaxFollowing is the syntax −Returning string valueinputColorObject.defaultValueSetting defaultValue to stringinputColorObject.defaultValue = ‘string’Boolean ValueHere, “string” can be the following −booleanValueDetails#000000 - #ffffffIt defines that input color can have a default value between the defined rangeExampleLet us see an example of Input Color defaultValue property − Live Demo Input Color Default Value Color Picker: Get Default Value var divDisplay = document.getElementById("divDisplay"); var inputColor = document.getElementById("Color"); function getDefaultValue() { ... Read More
The HTML DOM Input Time autofocus property sets/returns whether Input Time is focused upon initial page load.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputTimeObject.autofocusSetting autofocus to booleanValueinputTimeObject.autofocus = booleanValueBoolean ValuesHere, “booleanValue” can be the following:booleanValueDetailstrueIt defines that input will be autofocused on initial page load.falseIt is the default value and input is not autofocused.ExampleLet us see an example of Input Time autofocus property − Live Demo Input Time autofocus form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; ... Read More
Both str() and repr() methods in python are used for string representation of a string. Though they both seem to serve the same puppose, there is a little difference between them.Have you ever noticed what happens when you call a python built-in function str(x) where x is any object you want? The return value of str(x) depends on two methods: __str__ being the default choice and __repr__ as a fallback.Let’s first see what python docs says about them −>>> help(str) Help on class str in module builtins: class str(object) | str(object='') -> str | str(bytes_or_buffer[, encoding[, errors]]) -> str ... Read More
Ethereum Mining GuideEthereum Blockchain BasicsAs we all know, cryptocurrency mining is a process of solving complicated mathematical puzzles and miners play a crucial role in any cryptocurrency network as they spend their time and computing power to puzzle out those math problems, giving a ‘proof of work’ for the network, which verifies Ether transactions. Other than this, miners are responsible for making new Ether tokens through this process. This way, they get rewards in Ether for successfully completing a proof of work task.The more miners join the group, the puzzles automatically turn out more difficult to solve. This leads to ... Read More
To set limit to $inc, use the below syntax −db.yourCollectionName.update({yourFieldName : {$lt : yourValue}}, {$inc : {yourFieldName : yourIncrementValue}}, false, true);Let us first create a collection with documents −> db.limitIncrementDemo.insertOne({"StudentId":101, "StudentScore":95}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2ce9eb64f4b851c3a13c3") } > db.limitIncrementDemo.insertOne({"StudentId":102, "StudentScore":55}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2cea0b64f4b851c3a13c4") } > db.limitIncrementDemo.insertOne({"StudentId":103, "StudentScore":67}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2cea1b64f4b851c3a13c5") } > db.limitIncrementDemo.insertOne({"StudentId":104, "StudentScore":56}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2cea3b64f4b851c3a13c6") } > db.limitIncrementDemo.insertOne({"StudentId":105, "StudentScore":79}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2cea4b64f4b851c3a13c7") }Following is the query to display all documents ... Read More
Use FlowLayout.RIGHT to arrange components in a FlowLayout to be right-justified. −JFrame frame = new JFrame("Language"); frame.setLayout(new FlowLayout(FlowLayout.RIGHT));The following is an example to arrange components in a flow to be right-justified −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Language"); frame.setLayout(new FlowLayout(FlowLayout.RIGHT)); JLabel label = new JLabel("Most Spoken Language "); label.setPreferredSize(new Dimension(220, 70)); label.setOpaque(true); label.setBackground(Color.RED); ... Read More
To display tick marks in a JSlider, you need to use the setPaintTicks() method and set it to TRUE −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 75); slider.setPaintTicks(true);The following is an example to display tick marks in a slider in Java −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, 100, 75); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); ... Read More
ECMAScript 5 has introduced several methods to prevent modification of object. Those preventive measures ensures that no one, accidentally or otherwise change functionality of object.There are 3 levels of preventive methods1) Prevent ExtensionsIn this level, one cannot add any new properties or methods but can access existing properties or methods. Here there is an ability to delete the respective object. Object.preventExtensions() is the method used to accomplish this task. It prevents any new properties from ever being added to the object.ExampleLive Demo var object1 = { prop1: 1 ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP