- 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 4337 Articles for Java 8
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
61 Views
The result FALSE for is FileHidingEnabled() means the hidden files are displayed in the FileChooser. The following will display FALSE since file isn’t hidden −JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); boolean res = file.isFileHidingEnabled();Above, at first, we have displayed the file by setting hidden to be FALSE −file.setFileHidingEnabled(false);The following is an example −Examplepackage my; import javax.swing.JFileChooser; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); boolean res = file.isFileHidingEnabled(); System.out.println("File are ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
84 Views
To set the JSlider vertical, use the VERTICAL constant while creating the slider. Let us create a new Slider −JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);The other parameter values set above allows you to include the minimum, maximum and the initial value of the slider.The following is an example to set the slider vertical and move bottom-to-top −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60); ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
90 Views
Let us see how to set the raised SoftBevelBorder −Border raisedBorder = new SoftBevelBorder( SoftBevelBorder.RAISED, Color.GREEN, Color.GREEN.darker(), Color.MAGENTA, Color.magenta.brighter());Let us see how to set the lowered SoftBevelBorder −Border loweredBorder = new SoftBevelBorder( SoftBevelBorder.LOWERED, Color.ORANGE, Color.YELLOW.darker(), Color.BLUE, Color.yellow.brighter());The following is an example to set raised and lowered SoftBevelBorder for components in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.Border; import javax.swing.border.SoftBevelBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
751 Views
To set title position, use the setTitlePosition() method in Java. Let’s say we have to position the title above the border's top line. For that, use the constant ABOVE_TOP for the border −setTitlePosition(TitledBorder.ABOVE_TOP);The following is an example to set title position −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); LineBorder lineBorder = new LineBorder(Color.orange); TitledBorder titledBorder = BorderFactory.createTitledBorder(lineBorder, "Demo Title"); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
98 Views
To set TitleBorder direction, you need to use the constants and set it for border. For example, for direction center −TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER);Above, we have set the setTitlePosition() for the direction.The following is an example to set TitledBorder direction in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER); TitledBorder border2 = new TitledBorder( ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
220 Views
To set the border color for SoftBevelBorder in Java, use the Color class and set the color while creating the border −SoftBevelBorder border = new SoftBevelBorder( BevelBorder.RAISED, Color.ORANGE, Color.ORANGE.darker(), Color.BLUE, Color.magenta.brighter());We have set the following colors above as parameters −highlightOuterColor: color to use for the bevel outer highlight highlightInnerColor : color to use for the bevel inner highlight shadowOuterColor : color to use for the bevel outer shadow shadowInnerColor : color to use for the bevel inner shadowThe following is an example to set border color for SoftBevelBorde in Java −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
270 Views
To set the titled justification of the titled border, use the setTitleJustification() method. The following is an example to set the title justification of the titled border −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); LineBorder linedBorder = new LineBorder(Color.YELLOW); TitledBorder titledBorder = BorderFactory.createTitledBorder(linedBorder, "Demo Title"); titledBorder.setTitleJustification(TitledBorder.LEFT); JLabel label = new JLabel(); ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
250 Views
Here, we will see how to add a title to an existing Line border. Let’s say we have a label and the border is to be set −LineBorder linedBorder = new LineBorder(Color.blue); TitledBorder titledBorder = BorderFactory.createTitledBorder(linedBorder, "Demo Title"); JLabel label = new JLabel(); label.setBorder(titledBorder);The following is an example to add a title to an existing line border −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
82 Views
Yes, we can create nested TitledBorder. Let us first create a component for which we will set the border −JLabel label = new JLabel();Now, we will create the 1st border −TitledBorder border = BorderFactory.createTitledBorder("Top Border"); border.setTitlePosition(TitledBorder.TOP);Following is how we will creater border 2. We have set the 1st border here −TitledBorder border2 = new TitledBorder(border, "Bottom CENTER Border", TitledBorder.CENTER, TitledBorder.BOTTOM);Now, set it for the label component −label.setBorder(border2);The following is an example to create nested TitledBorder in Java −package my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.TitledBorder; public class SwingDemo { public static ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
60 Views
Let’s say the following is our JTextArea −JTextArea textArea = new JTextArea("This is demo text.");Now, get the font using the Font class getFont() method as shown below −Font font = textArea.getFont(); System.out.println("Font = "+font);The following is an example to get JTextArea font information in Java −Examplepackage my; import java.awt.Font; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo { SwingDemo(){ JFrame frame = new JFrame(); JTextArea textArea = new JTextArea("This is demo text."); Font font = textArea.getFont(); System.out.println("Font = "+font); frame.add(textArea); frame.setSize(550, 300); ... Read More