Arjun Thakur has Published 1109 Articles

How to create a List Spinner in Java?

Arjun Thakur

Arjun Thakur

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

261 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

373 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

3K+ 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

483 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

215 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

8085 program for hexadecimal counter

Arjun Thakur

Arjun Thakur

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

991 Views

Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to simulate the hexadecimal counter.Problem StatementWrite 8085 Assembly language program to simulate hexadecimal counter.DiscussionHexadecimal counters in 8085 is similar to the binary counter. There are two different parts. The main counting part and ... Read More

How to select all distinct filename extensions from a table of filenames in MySQL?

Arjun Thakur

Arjun Thakur

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

342 Views

You can use DISTINCT along with SUBSTRING_INDEX() to extract the filename extensions. Let us first create a table−mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FileName text    ); Query OK, 0 rows affected (0.75 sec)Insert records in the table using insert command ... Read More

How can we get the values of a JProgressBar Component and display in Console?

Arjun Thakur

Arjun Thakur

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

69 Views

Let’s say we have set the following values for JProgressBar −int min = 0; int max = 1000; progressBar = new JProgressBar(min, max);Now, get the above values and display in the Console −int value = progressBar.getValue(); System.out.println("Value = "+value); System.out.println("Minimum = "+progressBar.getMinimum()); System.out.println("Maximum = "+progressBar.getMaximum());The following is an example to ... Read More

HTML DOM addEventListener() Method

Arjun Thakur

Arjun Thakur

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

241 Views

The HTML DOM addEventListener() method is used to attach an event handler to the specified element.Following is the syntax −element.addEventListener(event, function, capture)Above, the parameters include −event: The name of the event. Required.function: The function to run when the event occurs. Required.capture: Whether the event should be executed in the capturing ... Read More

Advertisements