Hello,
I'm a little bit new to Java and I use NetBeans 6.5.1. I just try to make a window 'by code, manual' (not drag and drop, not visually).


This is my code (first I only want and empty window):

package javaapplication5;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;

import java.util.Calendar;
import java.text.SimpleDateFormat;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;

public class app extends
                JFrame 
                implements ActionListener, WindowListener{
// class members
      JFrame appFrame;


// class methods


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
       System.out.println("Application started");
       app app = new app();
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowOpened(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowClosing(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowClosed(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowIconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeiconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowActivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void windowDeactivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }



public void initialize() {
       
        appFrame = new JFrame("My apps title");
   
        appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        appFrame.setSize(400, 600);
        appFrame.setResizable(false);

    
        appFrame.pack();
        appFrame.setVisible(true);
        appFrame.addWindowListener(this);
}

    public void app()  {
        initialize();
    }


}

It prints the start mesage but I just don't know why it does not display the JFrame.
Help appreciated!

Hey you've written this method

public void app()  {
    initialize();
}

thinking that it's a constructor. haven't you?
Well constructor doesn't have any return type,not even void. So in this case it's not a constructor but a normal java method. So if you want to run your application,either remove void or call this method explicitly.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

:D Oh, my.... sorry... I never in my life made such a big mistake (I program in a lot of more languages, in java I'm just new but that doesn't matter here, no excuses). Maybe I've been a little sleepy... It works. SO, THANK YOU VERY MUCH! :)

Thread solved.

This question has already been answered. Start a new discussion instead.