George John has Published 1081 Articles

HTML min Attribute

George John

George John

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

146 Views

The min attribute of the element is used to set the minimum value for . Both min and max are used to set a range of value for input element with type number, date, datetime, range, etc. It introduced in HTML5.Let us now see an example to implement the ... Read More

Set whether the row in the table model can be selected or deselected in Java?

George John

George John

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

427 Views

We can set or disallow selection of row in the table using setRowSelectionAllowed().Let’s say the following is our table −DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel);If you want to allow selection of row, then set the method to TRUE −table.setRowSelectionAllowed(true);If you want to disallow selection of row, ... Read More

Java Program to display only vertical grid lines in a JTable

George John

George John

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

221 Views

At first, set the setShowGrid() to FALSE to disable all the grid lines. To display only vertical grid lines in a table, set the method setShowVerticalLines() to TRUE. Let us first create a table with rows and columns −String[][] rec = {    { "1", "Steve", "AUS" },    { ... Read More

Display all the titles of JTabbedPane tabs on Console in Java

George John

George John

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

444 Views

To display all the titles of the JTabbedPane, let us first get the count of tabs −int count = tabbedPane.getTabCount();Now, loop through the number of tabs in the JTabbedPane. Use the getTitleAt() to get the title of each and every tab −for (int i = 0; i < count; i++) ... Read More

How to set magins between cells of a JTable in Java?

George John

George John

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

683 Views

To set the margins i.e. row and columns margins between cells of a table, use the setIntercellSpacing() method −Dimension dim = new Dimension(50, 2); table.setIntercellSpacing(new Dimension(dim));Above, we have used the Dimension class −The following is an example to set margins between cells of a JTable cell −Examplepackage my; import java.awt.Dimension; ... Read More

How to retrieve the value from a table cell with TableModel in Java?

George John

George John

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

849 Views

At first, create a table with DefaultTableModel −String data[][] = {    {"Australia", "5", "1"},    {"US", "10", "2"},    {"Canada", "9", "3"},    {"India", "7", "4"},    {"Poland", "2", "5"},    {"SriLanka", "5", "6"} }; String col [] = {"Team", "Selected Players", "Rank"}; DefaultTableModel tableModel = new DefaultTableModel(data, col); ... Read More

How to disable a Tab in a JTabbedPane Container with Java?

George John

George John

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

3K+ Views

To disable a tab in a JTabbedPane container, use the setEnabledAt() method and set it to false with the index of the tab you want to disable.Let’s first create a JTabbedPane −JTabbedPane tabbedPane = new JTabbedPane();Now, let us disable a tab at index 2 −tabbedPane.setEnabledAt(2, false);The following is an example ... Read More

How can we change the default font of the JTabbedPane tabs in Java?

George John

George John

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

414 Views

To display the default font of the tabs, you need to use the Font class. Let’s say we created a JTabbedPane in Java −JTabbedPane tabbedPane = new JTabbedPane();Now, set the Font with font face, style and font size −Font font = new Font("Arial", Font.CENTER_BASELINE, 20); tabbedPane.setFont(font);The following is an example ... Read More

MySQL query to convert a string into a month (Number)?

George John

George John

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

286 Views

Use the str_to_date() method −select month(str_to_date(yourColumnName, '%b')) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    MonthName varchar(100)    ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to disable a MenuItem in Java?

George John

George John

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

1K+ Views

To disable a MenuItem, use the setEnabled() method and set it to FALSE. Let’s say we have the following MenuBar −JMenuBar menuBar = new JMenuBar();Now, create a Menu −JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);We will now create two MenuItems inside the above Menu −JMenuItem menuItem1 = new JMenuItem("New", KeyEvent.VK_N); ... Read More

Advertisements