Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 JFrame help
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
LiquidDragon




PostPosted: Wed Jul 07, 2004 9:03 am   Post subject: JFrame help

I am very new to java and it is very confusing. I started first with turing and now im onto java so i took this course. One of our labs was to create a program to maximize the size of the frame and put it at the top of the screen.

Here is what i have so far.

code:

/**
 * A JFrame that can double in width.
 */

import javax.swing.*;
import java.awt.*;

public class MaxWindow extends JFrame {
   
  Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
  int screenWidth= (int) d.getWidth();
  int screenHeight= (int) d.getHeight();
 
  public MaxWindow(String t) {
    super (t);
  }
 
  public MaxWindow() {
    // this automatically calls super().
  }
 
  public void maxWidth() {
    setSize (screenWidth, getHeight());
  }
 
  public void maxHeight() {
 
  }
}


NOTE: I am using DrJava to write and test all this. Any help would be great.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Wed Jul 07, 2004 9:00 pm   Post subject: (No subject)

ur trying to make a fullscreen window right?.. heh ask Dan, i know he did it for his FP.
Dan




PostPosted: Wed Jul 07, 2004 9:40 pm   Post subject: (No subject)

i do not think that is what he whonts, b/c he side maximised like the window mode. but i will post the fullscreen code just the same:

class from my FP that dose fullscreen:

code:

import java.awt.*;
import javax.swing.*;

/**
 *a fullscreen frame to be used for the game
 *@author Dan
 */
public class QFTBFrame extends JFrame
{       
        private GraphicsEnvironment env;
        private GraphicsDevice device;
        private boolean isFullScreen;
       
        /**
         *a new frame that will be fullscreen if the system suports it
         */
        public QFTBFrame()
        {
                super();
               
                env = GraphicsEnvironment.getLocalGraphicsEnvironment();
                device = env.getDefaultScreenDevice();
               
                isFullScreen = device.isFullScreenSupported();

                if(isFullScreen)
                {
                        setUndecorated(true);
                setResizable(false);
            device.setFullScreenWindow(this);
                }
                else
                {
                        setUndecorated(false);
                setResizable(true);
                        System.out.println("Error: your system dose not sport fullscreen, trying normal size...");
                }
        }
       
        /**
         *should take the system out of fullscreen mode (untested)
         */
        public void end()
        {
                if(isFullScreen)
                {
                        device.setFullScreenWindow(null);
                }
        }
}



fullscreen is a bit bugy esepltay when using it with GUIs like awt and swing and it dose not work on all systems.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
LiquidDragon




PostPosted: Thu Jul 08, 2004 5:51 pm   Post subject: (No subject)

It's not the fullscreen i want. I need to write a class that has a method that can maximize the width and another method to maximize the height. We are learning all this in a class im taking but i find java very confusing.
LiquidDragon




PostPosted: Fri Jul 09, 2004 7:24 pm   Post subject: (No subject)

It's ok now. I got some guy at U of T to help me Wink
Delta




PostPosted: Sat Jul 24, 2004 8:24 am   Post subject: (No subject)

Care to post your solution so if others have this problem it's already answered?
LiquidDragon




PostPosted: Sat Jul 24, 2004 5:33 pm   Post subject: (No subject)

I dont remember the problem anymore Embarassed
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: