Create a Border with a Raised Beveled Edge in Java

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

256 Views

Use the createRaisedBevelBorder() method to create a border with a raised beveled edge. We will set it on the label component −JLabel label; label = new JLabel("This has a border with a raised bevel edge!"); label.setBorder(BorderFactory.createRaisedBevelBorder());The following is an example to create a border with a raised beveled edge −Examplepackage my; import javax.swing.BorderFactory; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       JLabel label;       label = new JLabel("This has a border with a raised bevel edge!"); ... Read More

MongoDB Query to Replace Value in an Array

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

1K+ Views

Use $set to replace value in an array. Let us first create a collection with documents −> db.replaceValueInArrayDemo.insertOne({"StudentScores":[45, 56, 78]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0421a844af18acdffb7") } > db.replaceValueInArrayDemo.insertOne({"StudentScores":[33, 90, 67]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7f0521a844af18acdffb8") }Following is the query to display all documents from a collection with the help of find() method −> db.replaceValueInArrayDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd7f0421a844af18acdffb7"),    "StudentScores" : [       45,       56,       78    ] } {    "_id" : ObjectId("5cd7f0521a844af18acdffb8"),    "StudentScores" : [ ... Read More

HTML DOM Input Checkbox Value Property

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

571 Views

The Input Checkbox value property returns a string with the value attribute of input checkbox. User can also set it to a new string.SyntaxFollowing is the syntax −Returning string valueinputCheckboxObject.valueSetting value attribute to a string valueinputCheckboxObject.value = ‘String’ExampleLet us see an example of Input Checkbox value property − Live Demo Value Attribute of Checkbox Color-Red: Change value of input checkbox    var valueOfInput = document.getElementById("formCheckbox");    var displayDiv = document.getElementById("displayDiv");    displayDiv.textContent = 'Value: ' + valueOfInput.value;    function changeType(){       if(valueOfInput.value == 'Green' && valueOfInput.checked == true){   ... Read More

HTML DOM Input Text Type Property

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

230 Views

The HTML DOM Input Text type property returns/sets type of Input Text.SyntaxFollowing is the syntax −Returning string valueinputTextObject.typeSetting type to string valueinputTextObject.type = stringValueString ValuesHere, “stringValue” can be the following −stringValueDetailsemailIt defines that input type is emailtextIt defines that input type is textradioIt defines that input type is radiotelIt defines that input type is tel and a number keypad is shown for inputExampleLet us see an example of Input Text type property − Live Demo Input Text type    form {       width:70%;       margin: 0 auto;       text-align: center;    } ... Read More

Differences Between Python 2.x and Python 3.x

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

1K+ Views

There is always a debate in the coding community on which python version was the best one to learn: Python 2.x or Python 3.x.Below are key differences between pyton 2.x and python 3.x1. The print functionIn python 2.x, “print” is treated as a statement and python 3.x explicitly treats “print” as a function. This means we need to pass the items inside your print to the function parentheses in the standard way otherwise you will get a syntax error.#Python 2.7 print 'Python', python_version() print 'Hello, World!' print('Hello, World!') print "text", ; print 'some more text here'OutputPython 2.7.6 Hello, World! ... Read More

What is Ethereum?

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:26

263 Views

Before we talk about Ethereum let us first understand the concept of Decentralized network of Bitcoin which laid the foundation for the following Decentralized networks. Bitcoin digital currency was invented by Satoshi Nakamoto in 2009 as using a decentralized and transparent network.Bitcoin uses Cryptography + Proof of work + Decentralized network architecture together. The algorithm of Bitcoins is written in “Turing Incomplete” language, which understands only a limited set of orders like, who has sent the money, how much and who received it.While Bitcoin aims to remove a centralized authority to create the currency, Ethereum uses the Block Chain to ... Read More

Display 5 Different Cards in a CardLayout in Java

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

812 Views

Use CardLayout layout and set it to panel −JPanel panel = new JPanel(); CardLayout cardLayout = new CardLayout(); panel.setLayout(cardLayout);In the same way create 5 panels and 5 buttons to display 5 different cards.The following is an example to display 5 different cards in CardLayout −Examplepackage my; import java.awt.BorderLayout; import java.awt.CardLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       frame.setSize(550, 300);       JPanel panel = new JPanel();       JPanel panel1 = new JPanel();     ... Read More

Hide Track on the Slider in Java

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

270 Views

To hide the track on the slider, you need to use the setPaintTrack() method and set it to FALSE −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setInverted(true); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setPaintTrack(false);The above method setPaintTrack() is by default set to TRUE.The following is an example to hide the track on the slider −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, 55);   ... Read More

Get Part of String After Specified Character in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

15K+ Views

To get a part of a string, string.substring() method is used in javascript. Using this method we can get any part of a string that is before or after a particular character.str.substring() This method slices a string from a given start index(including) to end index(excluding). If only one index is provided then the method slice the entire string from the start of the index. syntax-1Using this line of code we can get a part of a string after a particular character.string.substring(string.indexOf(character) + 1);syntax-2Using this line of code we can get a part of a string before a particular character.string.substring(0, string.indexOf(character));ExampleLive Demo ... Read More

Absolute and Relative Imports in Python

Pradeep Elance
Updated on 30-Jul-2019 22:30:26

671 Views

Many times when we create python code we find that we need to access code from another python file or package. This is when you need to import that other python file or package into your current code. So the straight forward way to achieve this is just written the below statement at the top of your current python program.import package_name or module_name or from pacakge_name import module_name/object_nameWhen the above statement is parsed the interpreter does the following.The interpreter will look for names in the cache of all modules that have already been imported previously. The name of this cache ... Read More

Advertisements