MMC
MMC

Reputation: 175

Can't see output of GUI after process complete and ran

I made my code successfully with no errors. However, when I run file, it gives a weird output to look at an oracle site instead of my output. How do I look at my results?

import java.awt.*;
import javax.swing.*;

public class Frame extends JFrame {
public Frame() {
    //Create first Panel == p1
    JPanel p1 = new JPanel(new GridLayout(3, 3, 5, 5));

    p1.add(new JLabel("Input first number: "));
    p1.add(new JTextField(8));
    p1.add(new JLabel("Input second number: "));
    p1.add(new JTextField(1));
    p1.add(new JLabel("Results: "));
    p1.add(new JTextField(8));

    //Create second Panel == p2
    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 2));
    p2.add(new JButton("Add"));
    p2.add(new JButton("Subtract"));
    p2.add(new JButton("Multiply"));
    p2.add(new JButton("Divide"));

    setLayout(new GridLayout(2, 1, 5, 5));
    add(p1);
    add(p2);
    }

public static void main(String[] args) {
    Frame frame = new Frame();
    frame.setTitle("*****Calculator*****");
    frame.setSize(450, 400);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    }
} //end Frame Class

The weird output is:

--------------------Configuration: -------------------- Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM -hotspot is a synonym for the "client" VM [deprecated] The default VM is client. and so on....

Upvotes: 3

Views: 77

Answers (1)

Tanmay Patil
Tanmay Patil

Reputation: 7057

Don't import java.awt.*; There is a class java.awt.Frame which would interfere with your Frame class.

Consider renaming Frame class to something else. Also, please post the exact error/output.

Good luck.

Upvotes: 1

Related Questions