If you check this method in the main class - JFrame frame = new
QuarterScreenFrame("This is a test", 1);
I'm just not sure what value of topLeft to put..
This is the main class --
public class QuarterScreenTester {
public static void main(String[] args) {
JFrame frame = new QuarterScreenFrame("This is a test", 0,1);
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
-*-*-*-*******************************
This is the sub-class ---
public QuarterScreenFrame(String title, Point topLeft) // creates a
frame with title
{
super(title);
int width;
int height;
int x,y;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dimensions =toolkit.getScreenSize();
topLeft = new Point (dimensions.width, dimensions.height);
x = topLeft.x;
y = topLeft.y;
setBounds(0,0,x,y);
}
Roedy Green - 26 Sep 2007 05:44 GMT
>public QuarterScreenFrame(String title, Point topLeft) // creates a
>frame with title
[quoted text clipped - 9 lines]
>
> topLeft = new Point (dimensions.width, dimensions.height);
This makes no sense. Why do you pass a topLeft parameter then override
it?
Top Left is 0,0, yet topLeft points to bottom, right so your frame
will appear off screen to the bottom right.
see http://mindprod.com/jgloss/coordinates.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Andrew Thompson - 26 Sep 2007 06:14 GMT
...
> setBounds(0,0,x,y);
Roedy has already covered some of the questions
that others might ask about this code. But just
noticing that 'setBounds' I should point out that
it is almost always a sign of a very poor, fragile
GUI.
The best way to get the desired size is to overide
or set the preferred size, then pack() or validate()
the GUI. Calling setLocation() puts the frame
wherever on screen that it needs to be.
Further, the preferred size is usually best done
on components within frames, rather than the
frame itself. My basis for saying that, is the
almost inevitable (re)use of anything but the
most trivial components, in dialogs or option
panes, applets, or windows.
Use of appropriate layouts can arrange the UI
elements as needed.
There is a group specialised for GUI matters, it is
comp.lang.java.gui.

Signature
Andrew Thompson
http://www.athompson.info/andrew/
UKP - 26 Sep 2007 09:18 GMT
Thanks guys, I modified my code in a different way.
Andrew Thompson - 26 Sep 2007 12:23 GMT
>Thanks guys, I modified my code in a different way.
OK - fine, so... are you going to discuss *how* you
changed it, or are you just going to treat us as if we
were your personal 'help-desk servants'?

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Roedy Green - 26 Sep 2007 23:46 GMT
>The best way to get the desired size is to overide
>or set the preferred size, then pack() or validate()
>the GUI. Calling setLocation() puts the frame
>wherever on screen that it needs to be.
In other words, use a LayoutManager or write your own. Don't pepper
business logic with absolute positioning.
http://mindprod.com/jgloss/layout.html
http://mindprod.com/jgloss/layoutmanager.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com