Advertisement
Guest User

Java canvas problem

a guest
Jan 12th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.BorderLayout;
  2. import java.awt.Canvas;
  3. import java.awt.Dimension;
  4.  
  5. import javax.swing.JFrame;
  6.  
  7.  
  8. public class test extends Canvas {
  9.     public static final int WIDTH = 180;
  10.     public static final int HEIGHT = 250;
  11.     private JFrame frame;
  12.    
  13.     public test() {
  14.         setMinimumSize(new Dimension(WIDTH,HEIGHT));
  15.         setMaximumSize(new Dimension(WIDTH,HEIGHT));
  16.         setPreferredSize(new Dimension(WIDTH,HEIGHT));
  17.        
  18.         frame = new JFrame();
  19.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20.         frame.setLayout(new BorderLayout());
  21.         frame.add(this, BorderLayout.CENTER);
  22.         frame.pack();
  23.         frame.setResizable(false);
  24.         frame.setLocationRelativeTo(null);
  25.         frame.setVisible(true);
  26.  
  27.         System.out.println(getWidth());
  28.     }
  29.  
  30.     public static void main(String[] args) {
  31.         new test();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement