A JFrame is a little more than just a regular java app. You must extend and import a bunch of graphics classes included with JDK. To do this you need the following:

import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.StringTokenizer;
import javax.swing.*;
import javax.swing.border.*;

public class ClassName extends JFrame {

static Container c;
static JFrame x;
static Int Config_Width;
static Int Config_Height;
static Int WindowX;
static Int WindowY;

public static void main(String[] args) throws IOException {

x = new ClassName();
x.setSize(config_width, config_height);
x.setLocation(windowX, windowY);

Here is a small list of JFrame variables and what they do:

  • SetSize(config_width, config_height); - changes the size of the window
  • setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - I believe this adds the close button on the upper right corner.
  • setResizeable(true/false); - can you drag the window edges to resize it?
  • setAlwaysOnTop(true/false); - basically a "pin window" command, making it on top of everything else, even if it is out of focus.
  • setVisible(true/false); - is the window visible? It can exist, but it doesn't have to actually work.
  • setLocation(windowX, windowY); - sets the initial position of the upper left-hand corner of the window with respect to the upper left-hand corner of the monitor (starting at (0,0)).

No comments :

Post a Comment

Comment loud, comment often. But comment on the content!

All comments are filtered through to my email, so your spam will never make it. Unless, of course, you wanted to try injection attacks into my email, which would probably not happen since Blogger just tells me that a comment is awaiting moderation and doesn't bother to tell me what it says. I trust Blogger like that..