List of usage examples for java.awt Button setFont
public void setFont(Font f)
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//from w w w . j a v a2 s . c o m */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }