This snippet shows you all how to accommodate all the available fonts on your computer in a single window. I have taken for instance, 634 fonts.
|
Submitted By:
rishabhsharma
|
|
|
Rating:
|
| Views: 179 |
Language: Java |
| Last Modified: April 24, 2009 |
Snippet
import java.awt.*; //import some necessary package stuffs.
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
class AccommodatingFonts extends JFrame //extends JFrame to form main window
{
AccommodatingFonts() //constructor
{
setTitle("Available Fonts"); //setting title of the main window
Fonts = ge.getAvailableFontFamilyNames(); //getting available fonts
setSize(400,400); //size of the main window
fonts = new JList(Fonts ); //JList to accommodate all the fonts
fonts.setVisibleRowCount(100); //sets 100 fonts in a single vertical column
fonts. setLayoutOrientation(JList. VERTICAL_WRAP); //it wrap all the fonts vertically so as to divide th
//the fonts if could not be accommodated in a single vertical column i.e. after 100
add(pane); //adding scrollpane to the main window
}
String[] Fonts; //array to contain list of fonts
public static void main (String[] args )
{
new AccommodatingFonts().setVisible(true); //setting the main window visibility to true
}
}
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|
What's Here?
- Members: 358,291
- Replies: 966,103
- Topics: 163,335
- Snippets: 4,996
- Tutorials: 1,330
- Total Online: 2,464
- Members: 144
- Guests: 2,320
|