I'm trying to make this work, and I keep getting errors, can someone fix it and show me what's wrong? I've been trying to fix this for a few days and I can't. Thanks in advance.

import java.awt.*;
import java.applet.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;

public class FrameX extends Frame {

    JFrame frame = new JFrame("FrameX Project");
        // Add a window listner for close button
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        // This is an empty content area in the frame
        FrameXLabel FrameXlbempty = new Label("");
        FrameXlbempty.setPreferredSize(new Dimension(500, 500));
        frame.getContentPane().add(FrameXlbempty, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
    public static void main(String args[]){ 
       Frame objFrame1;
       Button objButton1;
       Button objButton2;
       Button objButton3;
       TextField objTextField1; 

       objFrame1 = new Frame
       objButton1 = new Button("This is button 1.");
       objButton2 = new Button("This is button 2.");
       objButton3 = new Button("This is button 3.");
       objTextField1 = new TextField(" Type Here ",0); 

       objButton1.setBounds(300, 150, 50, 40);
       objButton2.setBounds(400, 200, 100, 85);
       objButton3.setBounds(200, 190, 90, 75);
       objTextField1.setBounds(300, 150, 50, 40);

       objFrame1.add(objButton1);
      objFrame1.add(objButton2);
       objFrame1.add(objButton3);
       objFrame1.add(objTextField1);
    }

}

could you specify "keep getting errors"?
compile vs run time? stack traces? error messages? ...

here's one:

objFrame1 = new Frame

should at least be:

objFrame1 = new Frame();

I keep getting frame.addWindowListener(new WindowAdapter() { "identifier expected"

that code has to be within a method, not outside in a class. next to that, why extending Frame? don't go for AWT, switch to Swing with JFrame.

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.