- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4336 Articles for Java 8
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
272 Views
To create a vertical ProgressBar, use the following property −JProgressBar.VERTICALSet it like this −JProgressBar progressBar = new JProgressBar(JProgressBar.VERTICAL,0, 1000);The following is an example to create a vertical ProgressBar −Examplepackage my; import java.awt.Color; import javax.swing.*; public class SwingDemo extends JFrame { JProgressBar progressBar; int i = 0; SwingDemo() { progressBar = new JProgressBar(JProgressBar.VERTICAL,0, 1000); progressBar.setBounds(70, 50, 120, 30); progressBar.setValue(0); progressBar.setStringPainted(true); add(progressBar); setSize(550, 150); setLayout(null); } public void inc() { while (i
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
228 Views
Use the setBounds() method to set Bounds for JProgressBar in Java Swing −JProgressBar progressBar; progressBar.setBounds(70, 50, 120, 30);The following is an example to set bounds for JProgressBar −Examplepackage my; import javax.swing.*; public class SwingDemo extends JFrame { JProgressBar progressBar; int i = 0; SwingDemo() { progressBar = new JProgressBar(0, 1000); progressBar.setBounds(70, 50, 120, 30); progressBar.setValue(0); progressBar.setStringPainted(true); add(progressBar); setSize(550, 150); setLayout(null); } public void inc() { while (i
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
375 Views
To disable a JLabel, use the setEnabled() method −JLabel label; label.setEnabled(false);The following is an example to disable a JLabel −package my; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("First Label", JLabel.RIGHT); label.setVerticalAlignment(JLabel.TOP); label.setFont(new Font("Verdana", Font.PLAIN, 15)); label.setPreferredSize(new Dimension(250, 100)); label.setForeground(new Color(120, 90, 40)); label.setBackground(new Color(100, 20, 70)); label.setEnabled(false); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
7K+ Views
With Java Swing, you can set JLabel size as preferred size different than the default −JLabel label.setPreferredSize(new Dimension(250, 100));The following is an example to change JLabel size −Exampleimport java.awt.Color; import java.awt.Dimension; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("This is demo label!", JLabel.RIGHT); label.setVerticalAlignment(JLabel.TOP); label.setFont(new Font("Verdana", Font.PLAIN, 15)); label.setPreferredSize(new Dimension(250, 100)); label.setForeground(new Color(120, 90, 40)); label.setBackground(new ... Read More
![Rishi Raj](https://www.tutorialspoint.com/assets/profiles/13777/profile/60_73169-1512647303.jpg)
5K+ Views
The toString() method of the java.sql.Timestamp class returns the JDBC escape format of the time stamp of the current Timestamp object as String variable.i.e. using this method you can convert a Timestamp object to a String.//Retrieving the Time object Timestamp timestampObj = rs.getTimestamp("DispatchTimeStamp"); //Converting the Time object to String format String time_stamp = timestampObj.toString();ExampleLet us create a table with the name dispatches_data in MySQL database using CREATE statement as shown below:CREATE TABLE dispatches_data( ProductName VARCHAR(255), CustomerName VARCHAR(255), DispatchTimeStamp timestamp, Price INT, Location VARCHAR(255));Now, we will insert 5 records in dispatches_data table using INSERT statements:insert into ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
641 Views
Let’s say the following is our String List −List list = Arrays.asList("Football", "Basketball", "Hockey", "Cricket", "Fencing");Now, map to add string to each element −List str = list.stream().map(name -> "Sports " + name + " Outdoor") .collect(Collectors.toList());Above, we have added “Sports” and “Outdoor” strings to each element.The following is an example to Map and add string value to each element in Java −Exampleimport java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Demo { public static void main(String[] args) { List list = Arrays.asList("Football", "Basketball", "Hockey", "Cricket", "Fencing"); List str = list.stream().map(name -> "Sports " ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
411 Views
Let’s say the following is our String List −List list = new ArrayList(); list.add("ABC"); list.add("CDE"); list.add("GHI"); list.add("MNO"); list.add("GWE"); list.add("WDF"); list.add("JYH"); list.add("TYU");Map String List to lowercase −list .stream() .map(String::toLowerCase)After that, perform sorting −sorted((val1, val2) -> val2.compareTo(val1))The following is an example to Map string list to lowercase and sort −Exampleimport java.util.ArrayList; import java.util.List; public class Demo { public static void main(final String[] args) { List list = new ArrayList(); list.add("ABC"); list.add("CDE"); list.add("GHI"); list.add("MNO"); list.add("GWE"); list.add("WDF"); list.add("JYH"); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
364 Views
At first, we have set the stream −Stream.of(3.5, 4.7, 7.9, 8.2, 9.1, 10.5, 12.3, 15.8)Now to Map double to int Object, use mapToObj −.mapToInt(Double::intValue) .mapToObj(a -> "val" + a)The following is an example to Map double to int Object with mapToInt and mapToObj −Exampleimport java.util.stream.Stream; public class Demo { public static void main(String[] args) throws Exception { Stream.of(3.5, 4.7, 7.9, 8.2, 9.1, 10.5, 12.3, 15.8) .mapToInt(Double::intValue) .mapToObj(a -> "val" + a) .forEach(System.out::println); } }Outputval3 val4 val7 val8 val9 val10 val12 val15
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
156 Views
To Map IntStream to String object, use mapToObj and within that set the values −.mapToObj(val -> "z" + val)Before that, we used range() on IntStream −IntStream.range(1, 10)The following is an example to map IntStream to String object in Java −Exampleimport java.util.stream.IntStream; public class Demo { public static void main(String[] args) throws Exception { IntStream.range(1, 10) .mapToObj(val -> "z" + val) .forEach(System.out::println); } }Outputz1 z2 z3 z4 z5 z6 z7 z8 z9
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Let’s say the following is our String List −List list = Arrays.asList("Jonny", "David", "Tony", "Jacob", "Smith", "Bravo", "Gayle", "John");Now filter the string value with starting letter −Stream stream = list.stream().filter(name -> name.startsWith("J"));The following is an example to filter string value with starting letter −Exampleimport java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { List list = Arrays.asList("Jonny", "David", "Tony", "Jacob", "Smith", "Bravo", "Gayle", "John"); System.out.println("List with elements..."); for (String res : list) { System.out.print(res+" ... Read More