Arjun Thakur has Published 1025 Articles

Python program to Rearrange a string so that all same characters become d distance away

Arjun Thakur

Arjun Thakur

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

988 Views

Given a non-empty string str and an integer k , rearrange the string such that the same characters are at least distance k from each other.All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".Example 1:str = “tutorialspoint”, k = 3 Answer: “tiotiotalnprsu”The same ... Read More

How to add a tooltip to a component in Java?

Arjun Thakur

Arjun Thakur

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

504 Views

Let us first create a component −JLabel label1; label1 = new JLabel("Id", SwingConstants.CENTER); Now, set the tooltip for the above component − label1.setToolTipText("Enter Id");ExampleThe following is an example to add a tooltip to a component in Java −package my; import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Point; import javax.swing.JFrame; import javax.swing.JLabel; import ... Read More

How to set the titled justification (position title text) of the titled border in Java

Arjun Thakur

Arjun Thakur

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

403 Views

To set the titled justification of the titled border, use the setTitleJustification() method. The following is an example to set the title justification of the titled border −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo {   ... Read More

How to set raised and lowered SoftBevelBorder for components in Java. Also set the border color.

Arjun Thakur

Arjun Thakur

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

138 Views

Let us see how to set the raised SoftBevelBorder −Border raisedBorder = new SoftBevelBorder(    SoftBevelBorder.RAISED, Color.GREEN, Color.GREEN.darker(), Color.MAGENTA, Color.magenta.brighter());Let us see how to set the lowered SoftBevelBorder −Border loweredBorder = new SoftBevelBorder(    SoftBevelBorder.LOWERED, Color.ORANGE, Color.YELLOW.darker(), Color.BLUE, Color.yellow.brighter());The following is an example to set raised and lowered SoftBevelBorder for ... Read More

MongoDB query to find data from an array inside an object?

Arjun Thakur

Arjun Thakur

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

540 Views

Let us first create a collection with documents −> db.findDataDemo.insertOne(    {       "_id": new ObjectId(),       "CustomerName":"John",       "CustomerDetails" : {          "CountryName" : [             "AUS"          ],       ... Read More

How to get the depth of root node in a JTree with Java?

Arjun Thakur

Arjun Thakur

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

442 Views

To get the depth of root node in a JTree in Java, use the getDepth() method. Let’s say our root node is “node”, therefore, we will get the depth of root node like this −node.getDepth();The following is an example to get the depth of root node −Examplepackage my; import javax.swing.JFrame; ... Read More

HTML
cite Attribute

Arjun Thakur

Arjun Thakur

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

256 Views

The cite attribute of the element is used to set the source of a quotation. Following is the syntax −Above, url is the source of the quotation. Let us now see an example to implement the cite attribute of the element −Example Live Demo Magento Magento as stated ... Read More

NZEC error in Python?

Arjun Thakur

Arjun Thakur

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

898 Views

NZEC is non-zero exit code.Exit codes are codes (number) return by running program to operating system upon either their successfully termination (Exit code 0) or failed termination due to error (Non zero exit code).As python or Java programming language supports exception handling, we can use exception handling using try-catch blocks ... Read More

How to create etched border for a component using BorderFactory class in Java?

Arjun Thakur

Arjun Thakur

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

312 Views

The etched border gives an ‘etched’ look. Let’s say the following is our component −JLabel label; label = new JLabel("This has etched border with an 'etched' look!");Let us create an etched border with BorderFactory class −label.setBorder(BorderFactory.createEtchedBorder());The following is an example to create etched border for a component using BorderFactory class ... Read More

Which MongoDB query finds same value multiple times in an array?

Arjun Thakur

Arjun Thakur

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

128 Views

You can use $where operator along with some script.Let us first create a collection with documents −> dbsameValueMultipleTimesDemoinsertOne(    {       "ListOfPrice":[          {"Price": 110},          {"Price":130},          {"Price": 145}       ]    } ); {   ... Read More

Advertisements