?
Solved

JFrame Problem

Posted on 1999-11-24
4
Medium Priority
?
354 Views
Last Modified: 2010-08-05
I have make my ownclass, extends from JFrame, but I want when show method call, then It show in maximize state.
Any one can help ?
0
Comment
Question by:JavaBoy060299
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
sgoms earned 150 total points
ID: 2231442
how abt,

class myFrame extends JFrame{
  myFrame(){
   ////
setSize(Toolkit.getDefaultToolkit().getScreenSize().width,
Toolkit.getDefaultToolkit().getScreenSize().height);
   ////
  }
}

0
 
LVL 1

Expert Comment

by:jsridhar
ID: 2232094
sgoms method has a small hitch:
1. x,y are not set
2. since the size of the screen is used it will cover the task bar (in windows) as well

i tried:

setBounds(-4, -4, 808, 561);

to maximize the screen at startup and it worked for Windows in 800x500 resolution.

You can run the following code and check what will be the values for your os & screen config:

import java.awt.*;

public class Test extends Frame {

  public Test() {
    super("Test");
    setSize(200, 200);
    setVisible(true);
    enableEvents(1);
  }

  protected void processEvent(AWTEvent et) {
    System.out.println(et);
    super.processEvent(et);
  }

  public static void main(String args[]) {
    new Test();
  }
}
0
 

Author Comment

by:JavaBoy060299
ID: 2233217
jsridhar,

Thanks for your comments, but I prefer sqoms solution even it will cover a taskbar.

The problem, I don't know what user's screen resolution.

What about this ?
setSize(Toolkit.getDefaultToolkit().getScreenSize().width,
Toolkit.getDefaultToolkit().getScreenSize().height);

0
 

Author Comment

by:JavaBoy060299
ID: 2233218
Thanks
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month6 days, 12 hours left to enroll

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question