Arjun Thakur has Published 1025 Articles

How to align views at the bottom of the screen in Android?

Arjun Thakur

Arjun Thakur

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

6K+ Views

This example demonstrate about How to align views at the bottom of the screen in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java ... Read More

How to make an Android device vibrate programmatically?

Arjun Thakur

Arjun Thakur

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

738 Views

This example demonstrate about How to make an Android device vibrate programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 ... Read More

Add data to existing data in a MySQL Database?

Arjun Thakur

Arjun Thakur

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

814 Views

You can use CONCAT() function for this. Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(100)    ); Query OK, 0 rows affected (0.43 sec)Insert records in the table using insert command −mysql> insert into DemoTable(UserName) ... Read More

How to use AutoCompleteTextView in Android App?

Arjun Thakur

Arjun Thakur

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

238 Views

This example demonstrate about How to use AutoCompleteTextView in Android App.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.java     Step 3 − ... Read More

How to create a List Spinner in Java?

Arjun Thakur

Arjun Thakur

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

346 Views

For a List Spinner, use the SpinnerListModel class. At first, let us set a list −SpinnerListModel list = new SpinnerListModel(new String[] { "Football", "Cricket", "Hockey", "Squash", "Fencing" });Now, set it and create a new JSpinner −JSpinner spinner = new JSpinner(list);The following is an example to create a List Spinner −Examplepackage ... Read More

Java Program to set the Font and Color of some text in a JTextPane using Styles

Arjun Thakur

Arjun Thakur

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

3K+ Views

Let’s say the following is our JTextPane −JTextPane textPane = new JTextPane();Now, set the font style for some of the text −SimpleAttributeSet attributeSet = new SimpleAttributeSet(); StyleConstants.setItalic(attributeSet, true); textPane.setCharacterAttributes(attributeSet, true); textPane.setText("Learn with Text and ");For rest of the text, set different color −StyledDocument doc = textPane.getStyledDocument(); Style style = textPane.addStyle("", ... Read More

How do I exclude a specific record in MySQL?

Arjun Thakur

Arjun Thakur

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

433 Views

You can exclude a specific record in SQL using not equal to operator(!=). Let us first create a table−mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(20),    ClientCountryName varchar(10)    ); Query OK, 0 rows affected (0.64 sec)Insert records in the ... Read More

How to add ScrollBar to JList in Java?

Arjun Thakur

Arjun Thakur

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

4K+ Views

Let us first set a JList and add items −List myList = new ArrayList(10); for (int index = 0; index < 20; index++) {    myList.add("List Item " + index); }Now, we will set the above list to a new list −final JList list = new JList(myList.toArray(new String[myList.size()]));Now, set the ... Read More

How to select the first column in a JTable with Java?

Arjun Thakur

Arjun Thakur

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

644 Views

To select the first column in a JTable, use the setColumnSelectionInterval() method. Here, set the indexes as interval for one end as well as other end.For the first column, set the range as 0 and 0 since we want to only select the first column with index 0 −table.setColumnSelectionInterval(0, 0);The ... Read More

Can we use WHERE, AND & OR in a single MySQL query?

Arjun Thakur

Arjun Thakur

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

267 Views

Yes, we can use all of them in a single query. Let us first create a table −mysql> create table DemoTable    (    StudentId int,    StudentFirstName varchar(20),    StudentLastName varchar(20),    StudentAge int    ); Query OK, 0 rows affected (0.53 sec)Insert records in the table using insert ... Read More

Advertisements