Add JRadioButton to JTable Cell in Java

raja
Updated on 10-Feb-2020 08:59:20

1K+ Views

A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface. We can add or insert a radio button to a JTable cell by customizing the TableCellRenderer interface and the DefaultCellEditor class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class JTableRadioButtonTest extends JFrame {    private DefaultTableModel dtm;    private ButtonGroup bg;    private JTable table;    private JScrollPane jsp;    public JTableRadioButtonTest() {       setTitle("JTableRadioButton Test");   ... Read More

Synonym Statement for SHOW DATABASES in MySQL

Priya Pallavi
Updated on 10-Feb-2020 08:13:51

152 Views

As we know that with the help of SHOW DATABASES statement we can see the list of MySQL databases. Similarly, we can use SHOW SCHEMAS as the synonym of SHOW DATABASES to get the list of databases.Examplemysql> SHOW DATABASES; +--------------------+ | Database           | +--------------------+ | information_schema | | gaurav             | | mysql              | | performance_schema | | query              | | query1             | | sys                | | tutorials          | +--------------------+ 8 rows in set (0.07 sec) mysql> SHOW SCHEMAS; +--------------------+ | Database           | +--------------------+ | information_schema | | gaurav             | | mysql              | | performance_schema | | query              | | query1             | | sys                | | tutorials          | +--------------------+ 8 rows in set (0.00 sec)

Resemblance of COALESCE Function with IF-THEN-ELSE Statement

Arushi
Updated on 10-Feb-2020 08:12:53

628 Views

As we know that COALESCE() function returns first non-NULL value from the list of values. The following IF-THEN-ELSE statement is equivalent to COALESCE() function.IF value1 is not NULL THEN output = value1; ELSIF value2 is not NULL THEN output = value2; ELSIF value3 is not NULL THEN output = value3; . . . ELSIF valueN is not NULL THEN output = valueN; ELSE output = NULL; END IF;

MySQL COALESCE Function Returns When All Arguments are NULL

Arjun Thakur
Updated on 10-Feb-2020 08:11:47

1K+ Views

If all the values in MySQL COALESCE() function are NULL then it returns NULL as the output. It means that this function does not find any non-NULL value in the list.Examplemysql> Select COALESCE(NULL, NULL, NULL, NULL); +----------------------------------+ | COALESCE(NULL, NULL, NULL, NULL) | +----------------------------------+ |                             NULL | +----------------------------------+ 1 row in set (0.00 sec)

MySQL SUBSTRING Function with FROM and FOR Keywords

Chandu yadav
Updated on 10-Feb-2020 07:46:15

219 Views

The syntax of SUBSTRING() function using FROM and FOR keywords is the standard MySQL syntax.SyntaxSUBSTRING(str FROM pos FOR len)Here, str is the string from which substring would be returned.Pos is the starting position of substring.Len is the length of substring i.e. the total number of characters fetched from str.Examplemysql> Select SUBSTRING('foobarbar' FROM 4 FOR 5); +-------------------------------------+ | SUBSTRING('foobarbar' FROM 4 FOR 5) | +-------------------------------------+ | barba                               | +-------------------------------------+ 1 row in set (0.00 sec)The result set above, makes the use of FROM and FOR keywords very much clear in SUBSTRING() function.

Split Name String into Two Parts using MySQL SUBSTRING_INDEX Function

Fendadis John
Updated on 10-Feb-2020 07:22:10

326 Views

To make it understand, we are using the following data from a table named ‘customerdetail’.mysql> Select * from Customerdetail; +----------------------+----------------------+-----------+---------------------+ | Name                 | FName                | Address   | Emailid             | +----------------------+----------------------+-----------+---------------------+ | Advik Jhamb          | Lovkesh Jhamb        | Mumbai    | Advik@gmail.com     | | Chirag Jai Patil     | Raman Jai Patil      | Gujrat    | chirahp@yahoo.com   | | Devansh Singh Rajput | Kishore Singh Rajput ... Read More

MySQL SUBSTRING_INDEX Function with Negative Argument Count

Rama Giri
Updated on 10-Feb-2020 07:11:51

395 Views

MySQL SUBSTRING_INDEX() function can accept the negative value of argument ‘count’ and in this case, it returns the substring from the right of the final delimiter.Examplemysql> Select SUBSTRING_INDEX('www.google.com','.',-2); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-2) | +------------------------------------------+ | google.com                               | +------------------------------------------+ 1 row in set (0.00 sec) mysql> Select SUBSTRING_INDEX('www.google.com','.',-1); +------------------------------------------+ | SUBSTRING_INDEX('www.google.com','.',-1) | +------------------------------------------+ | com                                      | +------------------------------------------+ 1 row in set (0.00 sec)

Split IP Address into Four Octets Using MySQL SUBSTRING_INDEX Function

Chandu yadav
Updated on 10-Feb-2020 07:11:38

1K+ Views

Suppose we have a table named ‘ipaddress’ which contains the IP addresses as its values in column ‘IP’ as follows −mysql> Select * from ipaddress; +-----------------+ | ip              | +-----------------+ | 192.128.0.5     | | 255.255.255.255 | | 192.0.255.255   | | 192.0.1.5       | +-----------------+ 4 rows in set (0.10 sec)Now with the help of SUBSTRING_INDEX() function in the following query, we can divide the IP address in four octets −mysql> Select IP, SUBSTRING_INDEX(ip, '.', 1)AS '1st Part',     -> SUBSTRING_INDEX(SUBSTRING_INDEX(ip, '.', 2), '.', -1)AS '2nd Part',     ... Read More

Types of Selection Modes for a JList in Java

raja
Updated on 10-Feb-2020 07:01:22

870 Views

A JList is a component that can extend JComponent class used to display a list of objects that allows the user to select one or more items.There are three types of selection modes for a JList in JavaListSelectionModel.SINGLE_SELECTION: Only one list index can be selected at a time.ListSelectionModel.SINGLE_INTERVAL_SELECTION: Only one contiguous interval can be selected at a time.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: In this mode, there is no restriction on what can be selected. This is a default mode.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class JListSelectionModeTest extends JFrame implements ActionListener {    private JList list;    private DefaultListModel listModel;    public JListSelectionModeTest() {     ... Read More

Check the Status of MySQL Server

Nancy Den
Updated on 10-Feb-2020 06:48:48

1K+ Views

With the help of ‘mysqladmin’ along with ‘status’ option program we would be able to check the status of MySQL server. It can be used as follows on command line −C:\mysql\bin>mysqladmin -u root status Uptime: 3865 Threads: 1 Questions: 50 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 102 Queries per second avg: 0.012

Advertisements