SysFontInfo
import java.awt.*;
import java.awt.GraphicsEnvironment;
import java.awt.Dimension;
import javax.swing.*;
import java.io.*;
//import j2packs.BottomPanel;
//import j2packs.TopPanel;
public class SysFontInfo extends JFrame {
//cdm
String output ="", topTitle ="";
int count, txtrow, txtcol;
public static void main(String[] args){
SysFontInfo fontsavailable = new SysFontInfo();
fontsavailable.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
fontsavailable.setSize(400,300);
fontsavailable.setVisible(true);
}
public SysFontInfo(){
super("Fonts on this PlatForm");
displayFonts();
}
protected void displayFonts(){
Container pane = getContentPane();
pane.setBackground(Color.blue);
pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
JTextArea outputArea = new JTextArea(txtrow,txtcol);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension winSize = toolkit.getScreenSize();
output += "This computer has the following specs:\n";
output += "Screen resolution: " + toolkit.getScreenResolution();
output += "dots per inch.\n";
output += "Screen size: " + winSize.width + " x ";
output += winSize.height + "pixels\n";
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontnames = e.getAvailableFontFamilyNames();
output += "Font available on this platform:\n";
for(count = 0;count < fontnames.length;count++){
output += "" + (count+1) + "" + fontnames[count] + "\n";
}
//display
outputArea.setText(output);
outputArea.setFont(new Font("Tahoma",Font.PLAIN,14));
outputArea.setEditable(false);
pane.add(outputArea);
JScrollPane scrollpane = new JScrollPane(outputArea);
pane.add(scrollpane);
//add top and bottom panel
//topTitle = "SYSTEM INFORMATION";
// pane.add(new TopPanel(topTitle), BorderLayout.NORTH);
// pane.add(new BottomPanel(), BorderLayout.SOUTH);
}
}
No comments:
Post a Comment