I am supposed to write a programm for making a window.First of all, I must make a window with some given default values. Below is the code that I have been given as a template

 public class Window  {
    private String name;
    private int height;
    private int width;
    private String isActive;
    private String color;
    int[] WindowPoint=new int[2];

     public Window()
        WindowPoint[0] =0;
        WindowPoint[1] =0;


There's something that I cannot understand: In order to make a window, shouldn't I import the JFrame package and say that the Window class is a subclass of JFrame? If so, how can I have a Window constructor instead of using the JFrame built-in constructor in order to make my window? Is there another way to make a window, without using the JFrame or something similar?
Could someone explain this to me? Thank you in advance!

Recommended Answers

All 5 Replies

yes. a JFrame is what you describe as a "Window". you'll need to have your Window class extend the JFrame class and configure and initialize it correctly.

Thanks for your response! So ,it seems that inside the Window constructor I must call the JFrame constructor and somehow pass the values I'm given, right?

no. the constructor for Window is all you need. but your Window class has to extend JFrame.

Well, if I only write Window extends JFrame I get a small window at the upper left corner of my screen, without any title...

Ok, I got it! Here's the code and it works perfectly

  public Window()


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.