Author |
Message |
LiquidDragon
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
rizzix
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: 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! |
|
|
|
![](images/spacer.gif) |
LiquidDragon
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
LiquidDragon
|
Posted: 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 Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Delta
![](http://cg-clan.f2g.net/express_slower.gif)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
LiquidDragon
|
Posted: Sat Jul 24, 2004 5:33 pm Post subject: (No subject) |
|
|
I dont remember the problem anymore ![Embarassed Embarassed](http://compsci.ca/v3/images/smiles/icon_redface.gif) |
|
|
|
|
![](images/spacer.gif) |
|