Programming Articles

Page 2489 of 2547

Java Program to use Soft Bevel Border in Swing

Daniol Thomas
Daniol Thomas
Updated on 30-Jul-2019 300 Views

Here, we are creating soft beven border on JComboBox:JComboBox comboBox = new JComboBox(list);Now, set bevel border:comboBox.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));The following is an example to use soft bevel border in Swing:Exampleimport java.awt.Font; import java.awt.GridBagLayout; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.BevelBorder; import javax.swing.border.SoftBevelBorder; public class SwingDemo {    static final String list[] = { "One", "Two", "Three", "Four", "Five", "Six" };    public static void main(String[] args) {       JFrame window = new JFrame("ComboBox Example");       JPanel panel = new JPanel();       panel.setLayout(new GridBagLayout());       JComboBox comboBox = new JComboBox(list);       comboBox.setBorder(new ...

Read More

Java DatabaseMetaData getDatabaseProductName() method with example

Vikyath Ram
Vikyath Ram
Updated on 30-Jul-2019 1K+ Views

The getDatabaseProductName() method of the DatabaseMetaData interface returns the name of the underlying database in String format.To know the name of the underlying database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.Get the DatabaseMetaData object with respect to the current connection using the getMetaData() method of the Connection interface.Finally ...

Read More

C++ Program to Find Second Smallest of n Elements with Given Complexity Constraint

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 192 Views

This is a C++ program to find Second Smallest of n elements with given complexity constraint.AlgorithmBegin    function SecondSmallest() :       /* Arguments to this function are:          A pointer array a.          Number of elements n       */    // Body of the function:       A variable s1 is declared as to keep track of smallest number.       A variable s2 is declared as to keep track of second smallest number.       Initialize both s1 and s2 with INT_MAX.       Traverse ...

Read More

Java DatabaseMetaData getDatabaseMajorVersion() method with example

Arushi
Arushi
Updated on 30-Jul-2019 359 Views

The getDatabaseMajorVersion() method of the DatabaseMetaData interface returns the major version of the underlying database in integer format.To get major version of the underlying database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.Get the DatabaseMetaData object with respect to the current connection using the getMetaData() method of the Connection ...

Read More

How to make a JTree editable in Java?

George John
George John
Updated on 30-Jul-2019 699 Views

To make JTree editable in Java, use the TreeCellEditor class. With that, set the setEditable() method to true −TreeCellEditor editor = new DefaultCellEditor(textField); tree.setEditable(true); tree.setCellEditor(editor);The above will make the tree editable. The following is an example to make a JTree editable in Java −Examplepackage my; import javax.swing.DefaultCellEditor; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeCellEditor; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Products");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Clothing");       DefaultMutableTreeNode node2 = ...

Read More

Java DatabaseMetaData getColumns() method with example

Arushi
Arushi
Updated on 30-Jul-2019 4K+ Views

This method retrieves the description of the columns of a table. It accepts 4 parameters −catalog - A string parameter representing the name (or, name pattern) of the catalog (database in general) in which the table (that contains the columns of which you need to retrieve the description about) exists. pass "" to get the description of the columns in tables with no catalog and, pass null if you don't want to use catalog and thus narrow the search.schemaPattern - A String parameter representing the name (or, name pattern) of the schema of the table, pass "" if in case ...

Read More

Java DatabaseMetaData getDefaultTransactionIsolation() method with example

Arushi
Arushi
Updated on 30-Jul-2019 246 Views

In a database system where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction.The getDefaultTransactionIsolation() method of the DatabaseMetaData interface returns the default isolation level of the underlying database in integer format.To know the default transaction isolation of the underlying database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of ...

Read More

C++ Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers

Samual Sam
Samual Sam
Updated on 30-Jul-2019 234 Views

This is a C++ Program to find k numbers closest to Median of S, where S is a set of n numbers.AlgorithmsBegin    function partition() for partitioning the array on the basis of values at high as pivot value:    Arguments:       a[]=an array.       l=low    H=high    Body of the function:    Declare variables pivot, in, i    Initialize in = l    Set pivot = h    For i=l to h-1       if(a[i] < a[pivot])          swap a[i] and a[in])       increment in.       ...

Read More

What are the Selection Modes in a JTable with Java?

Chandu yadav
Chandu yadav
Updated on 30-Jul-2019 1K+ Views

Selection modes sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals. Let us see the selection modes one by one −Single Selection modeThe following is an example of Single Selection mode for a JTable. It allows you to select one cell at a time −Examplepackage my; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.border.TitledBorder; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       JPanel panel = new JPanel();       ...

Read More

C++ Program to Find ith Largest Number from a Given List Using Order-Statistic Algorithm

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 258 Views

This is a C++ program to find ith largest number from a given list using Order-Statistic Algorithm.AlgorithmsBegin    function Insert() to insert nodes into the tree:    Arguments:       root, d.       Body of the function:       If tree is completely null then insert new node as root.       If d = tmp->data, increase the count of that particular node.       If d < tmp->data, move the tmp pointer to the left child.       If d > tmp->data, move the tmp pointer to the right child. End Begin ...

Read More
Showing 24881–24890 of 25,469 articles
Advertisements