Get Tab Size of a JTextArea in Java

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

397 Views

To get the tab size from a JTextArea, you can use the getTabSize() method −textArea.getTabSize();We will assign it to int variable and display the size in the Console −int size = textArea.getTabSize(); System.out.println("Tab Size = "+size);The following is an example to set the tab size of a JTextArea −Examplepackage my; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo {    SwingDemo() {       JFrame frame = new JFrame();       JTextArea textArea = new JTextArea("This is demo text.");       int size = textArea.getTabSize();       System.out.println("Tab Size = "+size);       frame.add(textArea);     ... Read More

Update MySQL Field by Adding Value from Another Table

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

143 Views

Let us first create a table −mysql> create table DemoTable1    (    value int    ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;Output+-------+ | value | +-------+ | 10 | +-------+ 1 row in set (0.00 sec)Following is the query to create second table −mysql> create table DemoTable2    (    value1 int    ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table ... Read More

Check if a Column Name Exists in CachedRowSet in JDBC

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

3K+ Views

CachedRowSet interface does not provide any methods to determine whether a particular column exists.Therefore, to find whether a RowSet contains a specific column, you need to compare the name of each column in the RowSet with the required name. To do so −Retrieve the ResultSetMetaData object from the RowSet using the getMetaData() method.ResultSetMetaData meta = rowSet.getMetaData();Get the number of columns in the RowSet using the getColumnCount() method.int columnCount = meta.getColumnCount();The getColumnName() method returns the name of the column of the specified index. Using this method retrieve the column names of the RowSet from index 1 to column count and compare ... Read More

MySQL Query to Select Rows Older Than a Week

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

342 Views

For this, you can use DATEDIFF() function. The current date time is as follows −mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-09 19:15:56 | +---------------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> create table DemoTable -> ( -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.19 sec) ... Read More

HTML DOM previousElementSibling Property

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

158 Views

The HTML DOM previousElementSibling property returns the previous element in the same tree level of the specified element in an HTML document.SyntaxFollowing is the syntax −node.previousElementSiblingExampleLet us see an example of previousElementSibling property − Live Demo    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.2rem;    }    .drop-down{       width:50%;       border:2px solid #fff;       ... Read More

Difference Between Static Cast and C-Style Casting

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

4K+ Views

Here we will see what are the differences between static_cast and normal C style cast.The normal cast like (int)x is C style typecasting where static_cast(x) is used in C++.This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast the intensions are conveyed much better.In C like cast sometimes we can cast some type pointer to point some other type data.Like one integer pointer can also point character type data, as they are quite similar, only difference is character has ... Read More

Activate and Deactivate JFrame in Java

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

583 Views

Here, we are activating a frame. For deactivation, we have used dispose −Thread.sleep(2000); frame.setVisible(false);The frame first activates and then deactivates after 2 seconds since we have set sleep to 2000 miliseconds.The following is an example to activate and deactivate JFrame −Exampleimport java.awt.Frame; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo {    public static void main(String[] args) throws InterruptedException {       JFrame frame = new JFrame();       frame.add(new JLabel("Demo"));       frame.pack();       frame.setVisible(true);       Thread.sleep(2000);       frame.setState(Frame.ICONIFIED);       Thread.sleep(2000);       frame.setVisible(false);       frame.dispose(); ... Read More

Sizes of Icons in Android Notifications Action Buttons

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

174 Views

Asset Size: 32dp x 32dp Optical Square: 24dp x 24dp Color (Enabled): #FFFFFF 80% opacity Color (Disabled): #FFFFFF 30% opacityClick  here  to download the project code

Pull Even Numbers from an Array in MongoDB

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

616 Views

Use $mod to get the even numbers and pull them from the array. Let us first create a collection with documents −>db.pullEvenNumbersDemo.insertOne({"AllNumbers":[101, 102, 104, 106, 108, 109, 110, 112, 14, 17, 18, 21]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd45b072cba06f46efe9eea") }Following is the query to display all documents from the collection with the help of find() method −> db.pullEvenNumbersDemo.find().pretty();This will produce the following output −{    "AllNumbers" : [       102,       104,       106,       108,       109,       110,       112,   ... Read More

Display JTabbedPane on the Right in Java

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

165 Views

To display JTabbedPane on the right, you need to set the location to the right using the constant RIGHT −JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);The following is an example to display JTabbedPane on the right −Examplepackage my; import javax.swing.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Technologies");       JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);       JPanel panel1, panel2, panel3, panel4, panel5;       panel1 = new JPanel();       panel2 = new JPanel();       panel3 = new JPanel();       panel4 = ... Read More

Advertisements