Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How to fix this problem in Java part 2

Options
  • 28-02-2014 10:46pm
    #1
    Closed Accounts Posts: 5,678 ✭✭✭


    import javax.swing.*;
    class CenteredFrame extends JFrame 
    {
        public CenteredFrame()
        {
            // get screen dimensions 
            Toolkit kit = ToolKit.getDefaulToolkit();
            Dimension screenSize = kit.getScreenSize(); 
            int screenHeight = screenSize.height; 
            int screenWidth = screenSize.width; 
            
            // center frame in screen
            setSize(screenWidth / 2, screenHeight / 2);
            setLocation(screenWidth / 4, screenHeight / 4);
            
            // set frame icon and title
            Image img = kit.getImage("icon.gif");
            setIconImage(img);
            setTitle("centeredFrame");
        }} //CenteredFrameTest.java
    

    Whats wrong with this one ? Thanks


Comments

  • Registered Users Posts: 772 ✭✭✭maki


    import java.awt.*;

    Are you using an IDE? It should prompt you to fix missing imports.


  • Closed Accounts Posts: 5,678 ✭✭✭TrustedApple


    Using Blue J is shocking for telling you errors

    I am getting now cannot find symbol - variable Toolkit ?


  • Registered Users Posts: 772 ✭✭✭maki


    You have two typos. Should be:
    Toolkit kit = Toolkit.getDefaultToolkit();


Advertisement