Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

How to fix this problem in Java part 2

  • 28-02-2014 09: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, Registered Users 2 Posts: 774 ✭✭✭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, Registered Users 2 Posts: 774 ✭✭✭maki


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


Advertisement