Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tuplanolla.unnamed;
- import java.awt.*;
- import java.awt.event.*;
- /**
- dirty test case
- **/
- public class Test extends Canvas {
- private static Frame display = new Frame("Title");
- private static void init() {
- WindowListener window = new WindowAdapter() {
- public void windowOpened(WindowEvent event) {
- Font font = new Font("Times New Roman", Font.PLAIN, 32);
- FontMetrics metrics = display.getFontMetrics(font);
- display.setSize(metrics./*getMaxAdvance()*/charWidth('@')*32, metrics.getHeight()*8);
- Component component = new Label("", Label.CENTER);
- Label label = (Label)component;
- label.setText("This is not in Times New Roman.");
- label.setFont(font);
- label.setForeground(Color.GRAY);
- label.setBackground(Color.BLACK);
- display.add(component, BorderLayout.CENTER);
- }
- public void windowClosing(WindowEvent event) {
- display.setVisible(false);
- display.dispose();
- }
- public void windowClosed(WindowEvent event) {
- System.exit(0);
- }
- };
- display.addWindowListener(window);
- display.setResizable(false);
- display.setVisible(true);
- }
- public static void main(String[] argv) {
- Test test = new Test();
- test.init();
- }
- }
Add Comment
Please, Sign In to add comment