Ignore:
Timestamp:
05/19/08 12:03:18 (16 years ago)
Author:
ra33
Message:

Fixed a bunch of problems with rectangles and resizing the window, as well as adding some more unit tests etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Browser.java

    r50 r67  
    3131public class Browser extends JFrame implements ComponentListener,
    3232                WindowListener, WindowStateListener {
    33        
     33
    3434        /**
    3535         * Default version - just to stop eclipse from complaining about it.
     
    4040
    4141        public static Browser _theBrowser;
    42        
     42
    4343        /**
    4444         * Constructs a new Browser object, then launches it
     
    4949                _theBrowser = new Browser();
    5050                // Why do we want to ignore repaint?
    51                 // b.setIgnoreRepaint(true);
     51                //_theBrowser.setIgnoreRepaint(true);
    5252                _theBrowser.requestFocus();
    5353                // FrameGraphics.ForceRepaint();
    5454        }
    55        
     55
    5656        public void setSizes(Dimension size) {
    5757                setSize(size);
    5858                setPreferredSize(size);
    59                 addWindowListener(this);
    60                 addWindowStateListener(this);
    61 
     59
     60                FrameGraphics.setMaxSize(this.getContentPane().getSize());
     61        }
     62
     63        public Browser() {
     64                // Use the default values initially so we can load the profile frame
     65                setSizes(new Dimension(UserSettings.InitialWidth,
     66                                UserSettings.InitialHeight));
    6267                // center the frame on the screen
    6368                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    6469                double xpos = screen.getWidth() / 2;
    6570                double ypos = screen.getHeight() / 2;
    66                 setLocation((int) (xpos - (size.getWidth() / 2)), (int) (ypos - (size
    67                                 .getHeight() / 2)));
    68 
    69                 FrameGraphics.setMaxSize(this.getContentPane().getSize());
    70         }
    71 
    72         public Browser() {
    73                 // Use the default values initially so we can load the profile frame
    74                 setSizes(new Dimension(UserSettings.InitialWidth,
    75                                 UserSettings.InitialHeight));
     71                setLocation((int) (xpos - (UserSettings.InitialWidth / 2)),
     72                                (int) (ypos - (UserSettings.InitialHeight / 2)));
     73
     74                addWindowListener(this);
     75                addWindowStateListener(this);
    7676
    7777                UserSettings.Init();
    78                 UserSettings.Username = FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"));
     78                UserSettings.Username = FrameIO.ConvertToValidFramesetName(System
     79                                .getProperty("user.name"));
    7980                String userName = UserSettings.Username;
    8081                Frame profile = FrameIO.LoadProfile(userName);
     
    8384                                profile = FrameIO.CreateNewProfile(userName);
    8485                        } catch (Exception e) {
    85                                 //TODO tell the user that there was a problem creating the profile frame and close nicely
     86                                // TODO tell the user that there was a problem creating the
     87                                // profile frame and close nicely
    8688                                e.printStackTrace();
    87                                 assert(false);
     89                                assert (false);
    8890                        }
    8991                }
     
    9597                                UserSettings.InitialHeight));
    9698
    97                 //set the layout to absolute layout for widgets
     99                // set the layout to absolute layout for widgets
    98100                this.getContentPane().setLayout(new AbsoluteLayout());
    99                 //enable the glasspane-for capturing all mouse events
    100                 this.setGlassPane(new MouseEventRouter(getJMenuBar(), getContentPane()));
     101                // enable the glasspane-for capturing all mouse events
     102                this
     103                                .setGlassPane(new MouseEventRouter(getJMenuBar(),
     104                                                getContentPane()));
    101105                this.getGlassPane().setVisible(true);
    102106                this.getContentPane().setBackground(Color.white);
    103107                this.getContentPane().setFocusTraversalKeysEnabled(false);
    104                
     108
    105109                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    106110
     
    147151        private void setupGraphics() {
    148152                g = (Graphics2D) this.getContentPane().getGraphics();
    149                 assert g != null;
     153                assert (g != null);
    150154                g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
    151155                                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     
    154158        }
    155159
     160        // private int count = 0;
    156161        @Override
    157162        public void paint(Graphics g) {
     163                // All this does is make sure the screen is repainted when the browser
     164                // is moved so that some of the window is off the edge of the display
     165                // then moved back into view
    158166                super.paint(g);
    159167                FrameGraphics.Repaint();
     168                //System.out.println("Paint " + count++);
    160169        }
    161170
     
    166175                setSizes(this.getSize());
    167176                setupGraphics();
    168                 repaint();
     177                FrameIO.RefreshCasheImages();
     178                FrameGraphics.Repaint();
    169179        }
    170180
     
    211221        }
    212222
    213         /*
    214          * public void windowGainedFocus(WindowEvent e) { FrameGraphics.Repaint(); }
    215          *
    216          * public void windowLostFocus(WindowEvent e) { //FrameGraphics.Repaint(); }
    217          */
    218223        public void windowStateChanged(WindowEvent e) {
    219                 //FrameGraphics.Repaint();
    220                 //System.out.println('C');
     224                // FrameGraphics.Repaint();
     225                // System.out.println('C');
    221226        }
    222227
Note: See TracChangeset for help on using the changeset viewer.