Can we display a JTabPane with TextArea in one of the tabs with Java

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

308 Views

Yes, we can display a JTabPane with TextArea in one of the tabs. For that, let us first create a JTabbedPane component −JTabbedPane tabbedPane = new JTabbedPane();Now, create a text area you want to set under one of the tabs −JTextArea text = new JTextArea(100, 100);Now, set panels for the tabs. Under one of them, set the text area we created above as shown below −panel2 = new JPanel(); panel2.add(text); panel3 = new JPanel(); panel4 = new JPanel(); panel5 = new JPanel(); panel6 = new JPanel(); panel7 = new JPanel(); panel8 = new JPanel();Now, one by one create different tabs ... Read More

How to enable Scrolling Tabs in a JTabbedPane Container

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

436 Views

To enable scrolling tabs in a JTabbedPane container, use the setTabLayoutPolicy() method −tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);Above, we have set the constant to be SCROLL_TAB_LAYOUT, since we want the scroller to be visible when all the tabs won’t fit within a single run.The following is an example to enable scrolling tabs in a JTabbedPane container −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Devices");       JTabbedPane tabbedPane = new JTabbedPane();       JTextArea text = new JTextArea(100, 100);       JPanel panel1, panel2, panel3, ... Read More

How to set values to list of parameters of IN clause on PreparedStatement using JDBC?

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

4K+ Views

The IN clause in MYSQL database is used to specify the list of parameters in a query.For example, you need to retrieve contents of a table using specific IDs you can do so using the SELECT statement along with the IN clause as −mysql> SELECT * from sales where ID IN (1001, 1003, 1005); +------+-------------+--------------+--------------+--------------+-------+------------+ | ID   | ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location | +------+-------------+--------------+--------------+--------------+-------+------------+ | 1001 | Key-Board   | Raja         | 2019-09-01   | 11:00:00 | 8500 | Hyderabad ... Read More

How to perform string matching in MySQL?

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

353 Views

For string matching, use LIKE operator. Let us first create a table −mysql> create table DemoTable    -> (    -> MonthName varchar(100)    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JFMA'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('JMA'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JDN'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JFOSA'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement ... Read More

Absolute Difference between the Product of Non-Prime numbers and Prime numbers of an Array?

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

247 Views

Here we will see how we can find the absolute difference between the product of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a number is not divisible by any number between 2 to square root of that number. So this process will take 𝑂(√𝑛) amount of time. Then get the product and try to find the absolute difference.AlgorithmdiffPrimeNonPrimeProd(arr)begin    prod_p := product of all prime numbers in arr    prod_np := product of ... Read More

Difference between set, multiset, unordered_set, unordered_multiset in C++\\n

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

414 Views

Here we will see what are the differences for set, multiset, unordered_set and unordered_multiset in C++. Let us see the properties of them using some example.SetThe properties of set are like belowStores data in sorted orderStores only unique valuesWe can insert or delete data, but cannot change the dataWe can remove more than one element using start and end iteratorWe can traverse using iteratorsSets are implemented using Binary Search TreeNow let us see an exampleExample#include #include using namespace std; main() {    int data[15] = {11, 55, 22, 66, 33, 22, 11, 44, 77, 88, 66, 99, 66, 23, 41};    set my_set;    for(int i = 0; i

How to get all collections where collection name like '%2015%'?

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

598 Views

Let us first create some collections that starts from year number i.e. 2015, 2019, etc −> use web; switched to db web > db.createCollection("2015-myCollection"); { "ok" : 1 } > db.createCollection("2019-employeeCollection"); { "ok" : 1 } > db.createCollection("2015-yourCollection"); { "ok" : 1 }Now you can display all the collections with the help of SHOW −> show collections;This will produce the following output −2015-myCollection 2015-yourCollection 2019-employeeCollection applyConditionDemo check creatingAliasDemo emp_info emptyCollection removeNullDemoFollowing is the query to get all collections where collection name like ‘%2015%’ −> db.getCollectionNames().filter(function (v) { return /^2015\-/.test(v); })This will produce the following output −[ "2015-myCollection", "2015-yourCollection" ]If you ... Read More

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

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 to disable a tab in a JTabbedPane Container −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Devices");       JTabbedPane tabbedPane = new JTabbedPane();       JTextArea text = new JTextArea(100, 100); ... Read More

Is it Possible to store and retrieve boolean values in a VARCHAR2 column in a table using JDBC?

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

656 Views

Yes, in Oracle you can store and retrieve a boolean value into a table for a column with VARCHAR2 datatype.If you do so, the true and false values are stored as 1 and 0 and the retrieved as same (respectively).ExampleLet us create a table with name sampleTable in the Oracle database Using CREATE statement as −CREATE TABLE sampleTable(    ID INT,    ProductName VARCHAR (20) NOT NULL,    CustomerName VARCHAR (20) NOT NULL,    IsBillDue VARCHAR (20) NOT NULL,    DeliveryDate date,    Price INT,    Location varchar(20) );The column IsBillDue specified whether bill paid.Following JDBC program establishes the connection ... Read More

Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array?

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

281 Views

Here we will see how we can find the absolute difference between the sum of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a number is not divisible by any number between 2 to square root of that number. So this process will take 𝑂(√𝑛) amount of time. Then get the sum and try to find the absolute difference.AlgorithmdiffPrimeNonPrimeSum(arr)begin    sum_p := sum of all prime numbers in arr    sum_np := sum of ... Read More

Advertisements