Ankith Reddy has Published 1070 Articles

Division Operators in Python?

Ankith Reddy

Ankith Reddy

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

957 Views

Generally, the data type of an expression depends on the types of the arguments. This rule is applied to most of the operators: like when we add two integers ,the result should be an integer. However, in case of division this doesn’t work out well because there are two different ... Read More

Logical Operators on String in Python?

Ankith Reddy

Ankith Reddy

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

3K+ Views

Python logical operator “and” and “or” can be applied on strings. An empty string returns a Boolean value of False. Let’s first understand the behaviour of these two logical operator “and” and “or”.And operator Return the first falsey value if there are any, else return the last value in the expression ... Read More

HTML DOM Anchor origin Property

Ankith Reddy

Ankith Reddy

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

84 Views

The HTML DOM Anchor origin property returns the protocol, hostname and port number of the href attribute value, for example, http://www.demo.com:6064 Following is the syntax−anchorObj.originLet us now see an example to implement the DOM Anchor origin property −Example Live Demo Company Products Display href Part Display origin Display hreflang ... Read More

How to create a Default Cell Editor that uses a JComboBox in Java?

Ankith Reddy

Ankith Reddy

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

245 Views

Create a combo box first and set some values −JComboBox comboBox = new JComboBox(new String[]{"Product1", "Product2", "Product3", "Product4"});Seth the JComboBox for the editor so that the editor uses the combo box −TreeCellEditor editor = new DefaultCellEditor(comboBox); tree.setEditable(true); tree.setCellEditor(editor);The following is an example to create a Default Cell Editor that uses ... Read More

How to change JTable's header font in Java

Ankith Reddy

Ankith Reddy

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

1K+ Views

To change the table header font, you need to first get the header -JTableHeader tableHeader = table.getTableHeader();Now, use the Font class to set the new font. Here, we have set the font face to be Verdana, style as PLAIN and font size as 14 -Font headerFont = new Font("Verdana", Font.PLAIN, ... Read More

HTML DOM Anchor port Property

Ankith Reddy

Ankith Reddy

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

82 Views

The HTML DOM Anchor port property is used to set or return the port of the href attribute.Following is the syntax to set the port property−anchorObj.port = numAbove, num is the port number of the url.Following is the syntax to return the port property−anchorObj.portLet us now see an example to ... Read More

What is the maximum possible value of an integer in Python?

Ankith Reddy

Ankith Reddy

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

2K+ Views

Unlike C/C++ Long in Python 3 have unlimited precision and there is no explicitly defined limit. The amount of available address space considered to be the practical limit.In python 2, integers will automatically switch to longs when they grown beyond their limit −Python 2>>> import sys >>> type(sys.maxint) >>> ... Read More

How to add empty border to a JButton in Java?

Ankith Reddy

Ankith Reddy

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

359 Views

To add empty border to a component, use the BorderFactory class createEmptyBorder() method −Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 0, 0);To set the above border to a component, use the setBorder() method −JButton button = new JButton("Empty Border"); button.setBorder(emptyBorder);The following is an example to ad empty border to a JButton −Examplepackage ... Read More

How to prevent displaying any grid lines in a JTable?

Ankith Reddy

Ankith Reddy

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

211 Views

Let’s say the following is our table −String[][] rec = {    { "1", "Steve", "AUS" },    { "2", "Virat", "IND" },    { "3", "Kane", "NZ" },    { "4", "David", "AUS" },    { "5", "Ben", "ENG" },    { "6", "Eion", "ENG" }, }; String[] header ... Read More

Java Program to display both horizontal and vertical grid lines in a JTable

Ankith Reddy

Ankith Reddy

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

228 Views

To display both horizontal and vertical grid lines in a table, use the setShowGrid() method and set it to true −table.setShowGrid(true);The following is an example to display both horizonal and vertical grid lines in a JTable −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; public class ... Read More

Advertisements